diff --git a/Novetus/Novetus.Bootstrapper/LocalFuncs.cs b/Novetus/Novetus.Bootstrapper/LocalFuncs.cs index abcfe85..fbe5d71 100644 --- a/Novetus/Novetus.Bootstrapper/LocalFuncs.cs +++ b/Novetus/Novetus.Bootstrapper/LocalFuncs.cs @@ -16,7 +16,6 @@ namespace Novetus.Bootstrapper { public static void LaunchApplicationExt(string filePath, string appName, string args = "") { - FileManagement.Config(LocalPaths.ConfigPath, true); Util.LogPrint("Starting " + appName); try { @@ -39,7 +38,7 @@ namespace Novetus.Bootstrapper public static void LaunchApplication(string appName, string args = "") { - LaunchApplicationExt(LocalPaths.FixedBinDir, appName, args); + LaunchApplicationExt(GlobalPaths.BinDir, appName, args); } } #endregion diff --git a/Novetus/Novetus.Bootstrapper/LocalPaths.cs b/Novetus/Novetus.Bootstrapper/LocalPaths.cs index c945751..b1969bb 100644 --- a/Novetus/Novetus.Bootstrapper/LocalPaths.cs +++ b/Novetus/Novetus.Bootstrapper/LocalPaths.cs @@ -10,11 +10,6 @@ namespace Novetus.Bootstrapper public class LocalPaths { - public static readonly string FixedBinDir = GlobalPaths.BasePathLauncher + @"\\bin"; - public static readonly string FixedConfigDir = GlobalPaths.BasePathLauncher + @"\\config"; - public static readonly string FixedLogDir = GlobalPaths.BasePathLauncher + @"\\logs"; - public static readonly string FixedDataDir = FixedBinDir + @"\\data"; - #region File Names public static readonly string LauncherName = "Novetus.exe"; public static readonly string URIName = "NovetusURI.exe"; @@ -22,10 +17,10 @@ namespace Novetus.Bootstrapper #endregion #region File Paths - public static readonly string LauncherPath = FixedBinDir + "\\" + LauncherName; - public static readonly string InfoPath = FixedConfigDir + "\\" + GlobalPaths.InfoName; - public static readonly string VersionTermList = FixedConfigDir + "\\" + GlobalPaths.TermListFileName; - public static readonly string ConfigPath = FixedConfigDir + "\\" + GlobalPaths.ConfigName; + public static readonly string LauncherPath = GlobalPaths.BinDir + "\\" + LauncherName; + public static readonly string InfoPath = GlobalPaths.ConfigDir + "\\" + GlobalPaths.InfoName; + public static readonly string VersionTermList = GlobalPaths.ConfigDir + "\\" + GlobalPaths.TermListFileName; + public static readonly string ConfigPath = GlobalPaths.ConfigDir + "\\" + GlobalPaths.ConfigName; #endregion } #endregion diff --git a/Novetus/Novetus.Bootstrapper/NovetusLaunch.cs b/Novetus/Novetus.Bootstrapper/NovetusLaunch.cs index 4078dd6..f9a93e3 100644 --- a/Novetus/Novetus.Bootstrapper/NovetusLaunch.cs +++ b/Novetus/Novetus.Bootstrapper/NovetusLaunch.cs @@ -1,5 +1,6 @@ #region Usings using NLog; +using Novetus.Core; using System; using System.IO; using System.Windows.Forms; @@ -18,13 +19,13 @@ namespace Novetus.Bootstrapper Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); - if (!Directory.Exists(LocalPaths.FixedLogDir)) + if (!Directory.Exists(GlobalPaths.LogDir)) { - Directory.CreateDirectory(LocalPaths.FixedLogDir); + Directory.CreateDirectory(GlobalPaths.LogDir); } var config = new NLog.Config.LoggingConfiguration(); - var logfile = new NLog.Targets.FileTarget("logfile") { FileName = LocalPaths.FixedLogDir + "\\Bootstrapper-log-" + DateTime.Today.ToString("MM-dd-yyyy") + ".log" }; + var logfile = new NLog.Targets.FileTarget("logfile") { FileName = GlobalPaths.LogDir + "\\Bootstrapper-log-" + DateTime.Today.ToString("MM-dd-yyyy") + ".log" }; config.AddRuleForAllLevels(logfile); LogManager.Configuration = config; diff --git a/Novetus/Novetus.Bootstrapper/NovetusLaunchForm.cs b/Novetus/Novetus.Bootstrapper/NovetusLaunchForm.cs index 3a22bac..d04da3d 100644 --- a/Novetus/Novetus.Bootstrapper/NovetusLaunchForm.cs +++ b/Novetus/Novetus.Bootstrapper/NovetusLaunchForm.cs @@ -25,7 +25,7 @@ namespace Novetus.Bootstrapper ReadConfigValues(LocalPaths.ConfigPath); } - if (GlobalVars.UserConfiguration.BootstrapperShowUI) + if (GlobalVars.UserConfiguration.ReadSettingBool("BootstrapperShowUI")) { //use novetus font for label!! @@ -63,8 +63,7 @@ namespace Novetus.Bootstrapper void ReadConfigValues(string cfgpath) { - FileManagement.Config(cfgpath, false); - LauncherBox.Checked = !GlobalVars.UserConfiguration.BootstrapperShowUI; + LauncherBox.Checked = !GlobalVars.UserConfiguration.ReadSettingBool("BootstrapperShowUI"); } private void LaunchNovetusButton_Click(object sender, EventArgs e) @@ -115,7 +114,7 @@ namespace Novetus.Bootstrapper private void LauncherBox_CheckedChanged(object sender, EventArgs e) { - GlobalVars.UserConfiguration.BootstrapperShowUI = !LauncherBox.Checked; + GlobalVars.UserConfiguration.SaveSettingBool("BootstrapperShowUI", !LauncherBox.Checked); } } } diff --git a/Novetus/NovetusCore/CharCustom/CharacterCustomizationShared.cs b/Novetus/NovetusCore/CharCustom/CharacterCustomizationShared.cs index b0433a1..c481214 100644 --- a/Novetus/NovetusCore/CharCustom/CharacterCustomizationShared.cs +++ b/Novetus/NovetusCore/CharCustom/CharacterCustomizationShared.cs @@ -74,32 +74,32 @@ class CharacterCustomizationShared } //face - if (GlobalVars.UserCustomization.Face.Contains("http://") || GlobalVars.UserCustomization.Face.Contains("https://")) + if (GlobalVars.UserCustomization.ReadSetting("Face").Contains("http://") || GlobalVars.UserCustomization.ReadSetting("Face").Contains("https://")) { - Provider faceProvider = OnlineClothing.FindContentProviderByURL(contentProviders, GlobalVars.UserCustomization.Face); - FaceIDBox.Text = GlobalVars.UserCustomization.Face.Replace(faceProvider.URL, ""); + Provider faceProvider = OnlineClothing.FindContentProviderByURL(contentProviders, GlobalVars.UserCustomization.ReadSetting("Face")); + FaceIDBox.Text = GlobalVars.UserCustomization.ReadSetting("Face").Replace(faceProvider.URL, ""); FaceTypeBox.SelectedItem = faceProvider.Name; } //clothing - if (GlobalVars.UserCustomization.TShirt.Contains("http://") || GlobalVars.UserCustomization.TShirt.Contains("https://")) + if (GlobalVars.UserCustomization.ReadSetting("TShirt").Contains("http://") || GlobalVars.UserCustomization.ReadSetting("TShirt").Contains("https://")) { - Provider tShirtProvider = OnlineClothing.FindContentProviderByURL(contentProviders, GlobalVars.UserCustomization.TShirt); - TShirtsIDBox.Text = GlobalVars.UserCustomization.TShirt.Replace(tShirtProvider.URL, ""); + Provider tShirtProvider = OnlineClothing.FindContentProviderByURL(contentProviders, GlobalVars.UserCustomization.ReadSetting("TShirt")); + TShirtsIDBox.Text = GlobalVars.UserCustomization.ReadSetting("TShirt").Replace(tShirtProvider.URL, ""); TShirtsTypeBox.SelectedItem = tShirtProvider.Name; } - if (GlobalVars.UserCustomization.Shirt.Contains("http://") || GlobalVars.UserCustomization.Shirt.Contains("https://")) + if (GlobalVars.UserCustomization.ReadSetting("Shirt").Contains("http://") || GlobalVars.UserCustomization.ReadSetting("Shirt").Contains("https://")) { - Provider shirtProvider = OnlineClothing.FindContentProviderByURL(contentProviders, GlobalVars.UserCustomization.Shirt); - ShirtsIDBox.Text = GlobalVars.UserCustomization.Shirt.Replace(shirtProvider.URL, ""); + Provider shirtProvider = OnlineClothing.FindContentProviderByURL(contentProviders, GlobalVars.UserCustomization.ReadSetting("Shirt")); + ShirtsIDBox.Text = GlobalVars.UserCustomization.ReadSetting("Shirt").Replace(shirtProvider.URL, ""); ShirtsTypeBox.SelectedItem = shirtProvider.Name; } - if (GlobalVars.UserCustomization.Pants.Contains("http://") || GlobalVars.UserCustomization.Pants.Contains("https://")) + if (GlobalVars.UserCustomization.ReadSetting("Pants").Contains("http://") || GlobalVars.UserCustomization.ReadSetting("Pants").Contains("https://")) { - Provider pantsProvider = OnlineClothing.FindContentProviderByURL(contentProviders, GlobalVars.UserCustomization.Pants); - PantsIDBox.Text = GlobalVars.UserCustomization.Pants.Replace(pantsProvider.URL, ""); + Provider pantsProvider = OnlineClothing.FindContentProviderByURL(contentProviders, GlobalVars.UserCustomization.ReadSetting("Pants")); + PantsIDBox.Text = GlobalVars.UserCustomization.ReadSetting("Pants").Replace(pantsProvider.URL, ""); PantsTypeBox.SelectedItem = pantsProvider.Name; } } @@ -123,21 +123,21 @@ class CharacterCustomizationShared ReloadColors(); //icon - if (GlobalVars.UserCustomization.Icon.Contains("http://") || GlobalVars.UserCustomization.Icon.Contains("https://")) + if (GlobalVars.UserCustomization.ReadSetting("Icon").Contains("http://") || GlobalVars.UserCustomization.ReadSetting("Icon").Contains("https://")) { IconLabel.Text = "NBC"; } else { - IconLabel.Text = GlobalVars.UserCustomization.Icon; + IconLabel.Text = GlobalVars.UserCustomization.ReadSetting("Icon"); } //charid - CharacterIDBox.Text = GlobalVars.UserCustomization.CharacterID; + CharacterIDBox.Text = GlobalVars.UserCustomization.ReadSetting("CharacterID"); - ShowHatsInExtraBox.Checked = GlobalVars.UserCustomization.ShowHatsInExtra; + ShowHatsInExtraBox.Checked = GlobalVars.UserCustomization.ReadSettingBool("ShowHatsInExtra"); - if (GlobalVars.UserConfiguration.LauncherStyle == Settings.Style.Stylish) + if (GlobalVars.UserConfiguration.ReadSettingInt("LauncherStyle") == (int)Settings.Style.Stylish) { Color robBlue = Color.FromArgb(110, 152, 200); if (FormStyle == Settings.Style.Extended) @@ -221,9 +221,9 @@ class CharacterCustomizationShared FaceList.Items.Clear(); ExtraItemList.Items.Clear(); - if (GlobalVars.UserCustomization.Icon.Contains("http://") || GlobalVars.UserCustomization.Icon.Contains("https://")) + if (GlobalVars.UserCustomization.ReadSetting("Icon").Contains("http://") || GlobalVars.UserCustomization.ReadSetting("Icon").Contains("https://")) { - IconURLBox.Text = GlobalVars.UserCustomization.Icon; + IconURLBox.Text = GlobalVars.UserCustomization.ReadSetting("Icon"); LoadRemoteIcon(); } else @@ -246,7 +246,7 @@ class CharacterCustomizationShared ExtraItemList.Items.Clear(); ChangeItem( - GlobalVars.UserCustomization.Hat1, + GlobalVars.UserCustomization.ReadSetting("Hat1"), GlobalPaths.hatdir, "NoHat", Hat1Image, @@ -256,7 +256,7 @@ class CharacterCustomizationShared ); ChangeItem( - GlobalVars.UserCustomization.Hat2, + GlobalVars.UserCustomization.ReadSetting("Hat2"), GlobalPaths.hatdir, "NoHat", Hat2Image, @@ -266,7 +266,7 @@ class CharacterCustomizationShared ); ChangeItem( - GlobalVars.UserCustomization.Hat3, + GlobalVars.UserCustomization.ReadSetting("Hat3"), GlobalPaths.hatdir, "NoHat", Hat3Image, @@ -293,7 +293,7 @@ class CharacterCustomizationShared ExtraItemList.Items.Clear(); ChangeItem( - GlobalVars.UserCustomization.Face, + GlobalVars.UserCustomization.ReadSetting("Face"), GlobalPaths.facedir, "DefaultFace", FaceImage, @@ -320,7 +320,7 @@ class CharacterCustomizationShared ExtraItemList.Items.Clear(); ChangeItem( - GlobalVars.UserCustomization.TShirt, + GlobalVars.UserCustomization.ReadSetting("TShirt"), GlobalPaths.tshirtdir, "NoTShirt", TShirtImage, @@ -347,7 +347,7 @@ class CharacterCustomizationShared ExtraItemList.Items.Clear(); ChangeItem( - GlobalVars.UserCustomization.Shirt, + GlobalVars.UserCustomization.ReadSetting("Shirt"), GlobalPaths.shirtdir, "NoShirt", ShirtImage, @@ -374,7 +374,7 @@ class CharacterCustomizationShared ExtraItemList.Items.Clear(); ChangeItem( - GlobalVars.UserCustomization.Pants, + GlobalVars.UserCustomization.ReadSetting("Pants"), GlobalPaths.pantsdir, "NoPants", PantsImage, @@ -401,7 +401,7 @@ class CharacterCustomizationShared ExtraItemList.Items.Clear(); ChangeItem( - GlobalVars.UserCustomization.Head, + GlobalVars.UserCustomization.ReadSetting("Head"), GlobalPaths.headdir, "DefaultHead", HeadImage, @@ -427,7 +427,7 @@ class CharacterCustomizationShared FaceList.Items.Clear(); ChangeItem( - GlobalVars.UserCustomization.Extra, + GlobalVars.UserCustomization.ReadSetting("Extra"), GlobalPaths.extradir, "NoExtra", ExtraItemImage, @@ -436,17 +436,17 @@ class CharacterCustomizationShared true ); - if (GlobalVars.UserCustomization.ShowHatsInExtra) + if (GlobalVars.UserCustomization.ReadSettingBool("ShowHatsInExtra")) { ChangeItem( - GlobalVars.UserCustomization.Extra, + GlobalVars.UserCustomization.ReadSetting("Extra"), GlobalPaths.hatdir, "NoHat", ExtraItemImage, ExtraItemDesc, ExtraItemList, true, - GlobalVars.UserCustomization.ShowHatsInExtra + GlobalVars.UserCustomization.ReadSettingBool("ShowHatsInExtra") ); } break; @@ -472,12 +472,12 @@ class CharacterCustomizationShared #region Part/Color Funcs public void ReloadColors() { - HeadButton.BackColor = ConvertStringtoColor(GlobalVars.UserCustomization.HeadColorString); - TorsoButton.BackColor = ConvertStringtoColor(GlobalVars.UserCustomization.TorsoColorString); - RightArmButton.BackColor = ConvertStringtoColor(GlobalVars.UserCustomization.RightArmColorString); - LeftArmButton.BackColor = ConvertStringtoColor(GlobalVars.UserCustomization.LeftArmColorString); - RightLegButton.BackColor = ConvertStringtoColor(GlobalVars.UserCustomization.RightLegColorString); - LeftLegButton.BackColor = ConvertStringtoColor(GlobalVars.UserCustomization.LeftLegColorString); + HeadButton.BackColor = ConvertStringtoColor(GlobalVars.UserCustomization.ReadSetting("HeadColorString")); + TorsoButton.BackColor = ConvertStringtoColor(GlobalVars.UserCustomization.ReadSetting("TorsoColorString")); + RightArmButton.BackColor = ConvertStringtoColor(GlobalVars.UserCustomization.ReadSetting("RightArmColorString")); + LeftArmButton.BackColor = ConvertStringtoColor(GlobalVars.UserCustomization.ReadSetting("LeftArmColorString")); + RightLegButton.BackColor = ConvertStringtoColor(GlobalVars.UserCustomization.ReadSetting("RightLegColorString")); + LeftLegButton.BackColor = ConvertStringtoColor(GlobalVars.UserCustomization.ReadSetting("LeftLegColorString")); } public void ColorButton() @@ -523,34 +523,34 @@ class CharacterCustomizationShared switch (part) { case "Head": - GlobalVars.UserCustomization.HeadColorID = ColorID; - GlobalVars.UserCustomization.HeadColorString = ButtonColor.ToString(); - HeadButton.BackColor = ConvertStringtoColor(GlobalVars.UserCustomization.HeadColorString); + GlobalVars.UserCustomization.SaveSettingInt("HeadColorID", ColorID); + GlobalVars.UserCustomization.SaveSetting("HeadColorString", ButtonColor.ToString()); + HeadButton.BackColor = ConvertStringtoColor(GlobalVars.UserCustomization.ReadSetting("HeadColorString")); break; case "Torso": - GlobalVars.UserCustomization.TorsoColorID = ColorID; - GlobalVars.UserCustomization.TorsoColorString = ButtonColor.ToString(); - TorsoButton.BackColor = ConvertStringtoColor(GlobalVars.UserCustomization.TorsoColorString); + GlobalVars.UserCustomization.SaveSettingInt("TorsoColorID", ColorID); + GlobalVars.UserCustomization.SaveSetting("TorsoColorString", ButtonColor.ToString()); + TorsoButton.BackColor = ConvertStringtoColor(GlobalVars.UserCustomization.ReadSetting("TorsoColorString")); break; case "Right Arm": - GlobalVars.UserCustomization.RightArmColorID = ColorID; - GlobalVars.UserCustomization.RightArmColorString = ButtonColor.ToString(); - RightArmButton.BackColor = ConvertStringtoColor(GlobalVars.UserCustomization.RightArmColorString); + GlobalVars.UserCustomization.SaveSettingInt("RightArmColorID", ColorID); + GlobalVars.UserCustomization.SaveSetting("RightArmColorString", ButtonColor.ToString()); + RightArmButton.BackColor = ConvertStringtoColor(GlobalVars.UserCustomization.ReadSetting("RightArmColorString")); break; case "Left Arm": - GlobalVars.UserCustomization.LeftArmColorID = ColorID; - GlobalVars.UserCustomization.LeftArmColorString = ButtonColor.ToString(); - LeftArmButton.BackColor = ConvertStringtoColor(GlobalVars.UserCustomization.LeftArmColorString); + GlobalVars.UserCustomization.SaveSettingInt("LeftArmColorID", ColorID); + GlobalVars.UserCustomization.SaveSetting("LeftArmColorString", ButtonColor.ToString()); + LeftArmButton.BackColor = ConvertStringtoColor(GlobalVars.UserCustomization.ReadSetting("LeftArmColorString")); break; case "Right Leg": - GlobalVars.UserCustomization.RightLegColorID = ColorID; - GlobalVars.UserCustomization.RightLegColorString = ButtonColor.ToString(); - RightLegButton.BackColor = ConvertStringtoColor(GlobalVars.UserCustomization.RightLegColorString); + GlobalVars.UserCustomization.SaveSettingInt("RightLegColorID", ColorID); + GlobalVars.UserCustomization.SaveSetting("RightLegColorString", ButtonColor.ToString()); + RightLegButton.BackColor = ConvertStringtoColor(GlobalVars.UserCustomization.ReadSetting("RightLegColorString")); break; case "Left Leg": - GlobalVars.UserCustomization.LeftLegColorID = ColorID; - GlobalVars.UserCustomization.LeftLegColorString = ButtonColor.ToString(); - LeftLegButton.BackColor = ConvertStringtoColor(GlobalVars.UserCustomization.LeftLegColorString); + GlobalVars.UserCustomization.SaveSettingInt("LeftLegColorID", ColorID); + GlobalVars.UserCustomization.SaveSetting("LeftLegColorString", ButtonColor.ToString()); + LeftLegButton.BackColor = ConvertStringtoColor(GlobalVars.UserCustomization.ReadSetting("LeftLegColorString")); break; default: break; @@ -589,25 +589,13 @@ class CharacterCustomizationShared public void ResetColors() { ColorView.SelectedIndices.Clear(); - GlobalVars.UserCustomization.HeadColorID = 24; - GlobalVars.UserCustomization.TorsoColorID = 23; - GlobalVars.UserCustomization.LeftArmColorID = 24; - GlobalVars.UserCustomization.RightArmColorID = 24; - GlobalVars.UserCustomization.LeftLegColorID = 119; - GlobalVars.UserCustomization.RightLegColorID = 119; - GlobalVars.UserCustomization.CharacterID = ""; - GlobalVars.UserCustomization.HeadColorString = "Color [A=255, R=245, G=205, B=47]"; - GlobalVars.UserCustomization.TorsoColorString = "Color [A=255, R=13, G=105, B=172]"; - GlobalVars.UserCustomization.LeftArmColorString = "Color [A=255, R=245, G=205, B=47]"; - GlobalVars.UserCustomization.RightArmColorString = "Color [A=255, R=245, G=205, B=47]"; - GlobalVars.UserCustomization.LeftLegColorString = "Color [A=255, R=164, G=189, B=71]"; - GlobalVars.UserCustomization.RightLegColorString = "Color [A=255, R=164, G=189, B=71]"; - HeadButton.BackColor = ConvertStringtoColor(GlobalVars.UserCustomization.HeadColorString); - TorsoButton.BackColor = ConvertStringtoColor(GlobalVars.UserCustomization.TorsoColorString); - RightArmButton.BackColor = ConvertStringtoColor(GlobalVars.UserCustomization.RightArmColorString); - LeftArmButton.BackColor = ConvertStringtoColor(GlobalVars.UserCustomization.LeftArmColorString); - RightLegButton.BackColor = ConvertStringtoColor(GlobalVars.UserCustomization.RightLegColorString); - LeftLegButton.BackColor = ConvertStringtoColor(GlobalVars.UserCustomization.LeftLegColorString); + GlobalVars.UserCustomization.CreateFile(); + HeadButton.BackColor = ConvertStringtoColor(GlobalVars.UserCustomization.ReadSetting("HeadColorString")); + TorsoButton.BackColor = ConvertStringtoColor(GlobalVars.UserCustomization.ReadSetting("TorsoColorString")); + RightArmButton.BackColor = ConvertStringtoColor(GlobalVars.UserCustomization.ReadSetting("RightArmColorString")); + LeftArmButton.BackColor = ConvertStringtoColor(GlobalVars.UserCustomization.ReadSetting("LeftArmColorString")); + RightLegButton.BackColor = ConvertStringtoColor(GlobalVars.UserCustomization.ReadSetting("RightLegColorString")); + LeftLegButton.BackColor = ConvertStringtoColor(GlobalVars.UserCustomization.ReadSetting("LeftLegColorString")); } public void RandomizeColors() @@ -645,9 +633,10 @@ class CharacterCustomizationShared } } + // TODO: we don't really need these.... public void SaveOutfit(bool box = true) { - FileManagement.Customization(GlobalPaths.ConfigDir + "\\" + GlobalPaths.ConfigNameCustomization, true); + //FileManagement.Customization(GlobalPaths.ConfigDir + "\\" + GlobalPaths.ConfigNameCustomization, true); if (box) { MessageBox.Show("Outfit Saved!", "Novetus - Outfit Saved", MessageBoxButtons.OK, MessageBoxIcon.Information); @@ -664,7 +653,8 @@ class CharacterCustomizationShared ofd.Title = "Load config_customization.ini"; if (ofd.ShowDialog() == DialogResult.OK) { - FileManagement.Customization(ofd.FileName, false); + //FileManagement.Customization(ofd.FileName, false); + GlobalVars.UserCustomization.LoadAllSettings(ofd.FileName); ReloadColors(); MessageBox.Show("Outfit Loaded!", "Novetus - Outfit Loaded", MessageBoxButtons.OK, MessageBoxIcon.Information); } @@ -774,7 +764,7 @@ class CharacterCustomizationShared string mapfile = GlobalPaths.BasePathLauncher + "\\preview\\content\\fonts\\3DView.rbxl"; string rbxexe = GlobalPaths.BasePathLauncher + (GlobalVars.AdminMode ? "\\preview\\3DView_studio.exe" : "\\preview\\3DView.exe"); string quote = "\""; - string script = "_G.CS3DView(0,'" + GlobalVars.UserConfiguration.PlayerName + "'," + GlobalVars.Loadout + ");"; + string script = "_G.CS3DView(0,'" + GlobalVars.UserConfiguration.ReadSetting("PlayerName") + "'," + GlobalVars.Loadout + ");"; if (GlobalVars.AdminMode) { @@ -828,7 +818,7 @@ class CharacterCustomizationShared public void LoadLocalIcon() { - Image icon1 = Util.LoadImage(GlobalPaths.extradirIcons + "\\" + GlobalVars.UserConfiguration.PlayerName + ".png", GlobalPaths.extradir + "\\NoExtra.png"); + Image icon1 = Util.LoadImage(GlobalPaths.extradirIcons + "\\" + GlobalVars.UserConfiguration.ReadSetting("PlayerName") + ".png", GlobalPaths.extradir + "\\NoExtra.png"); IconImage.Image = icon1; SaveOutfit(false); @@ -843,15 +833,15 @@ class CharacterCustomizationShared IconURLBox.Text.Contains("NBC")) { IconURLBox.Text = ""; - GlobalVars.UserCustomization.Icon = "NBC"; - IconLabel.Text = GlobalVars.UserCustomization.Icon; + GlobalVars.UserCustomization.SaveSetting("Icon", "NBC"); + IconLabel.Text = GlobalVars.UserCustomization.ReadSetting("Icon"); BrowseIconButton.Enabled = true; LoadLocalIcon(); return; } else if (IconURLBox.Text.Contains("http://") || IconURLBox.Text.Contains("https://")) { - GlobalVars.UserCustomization.Icon = IconURLBox.Text; + GlobalVars.UserCustomization.SaveSetting("Icon", IconURLBox.Text); IconLabel.Text = "NBC"; BrowseIconButton.Enabled = false; } diff --git a/Novetus/NovetusCore/CharCustom/Forms/Compact/CharacterCustomizationCompact.cs b/Novetus/NovetusCore/CharCustom/Forms/Compact/CharacterCustomizationCompact.cs index 23bf7c3..6e2b5bc 100644 --- a/Novetus/NovetusCore/CharCustom/Forms/Compact/CharacterCustomizationCompact.cs +++ b/Novetus/NovetusCore/CharCustom/Forms/Compact/CharacterCustomizationCompact.cs @@ -39,15 +39,14 @@ public partial class CharacterCustomizationCompact : Form } #region Hats - void ListBox1SelectedIndexChanged(object sender, EventArgs e) { if (Directory.Exists(GlobalPaths.hatdir)) { - GlobalVars.UserCustomization.Hat1 = listBox1.SelectedItem.ToString(); + GlobalVars.UserCustomization.SaveSetting("Hat1", listBox1.SelectedItem.ToString()); characterCustomizationForm.ChangeItem( - GlobalVars.UserCustomization.Hat1, + GlobalVars.UserCustomization.ReadSetting("Hat1"), GlobalPaths.hatdir, "NoHat", pictureBox1, @@ -62,10 +61,10 @@ public partial class CharacterCustomizationCompact : Form { if (Directory.Exists(GlobalPaths.hatdir)) { - GlobalVars.UserCustomization.Hat2 = listBox2.SelectedItem.ToString(); + GlobalVars.UserCustomization.SaveSetting("Hat2", listBox2.SelectedItem.ToString()); characterCustomizationForm.ChangeItem( - GlobalVars.UserCustomization.Hat2, + GlobalVars.UserCustomization.ReadSetting("Hat1"), GlobalPaths.hatdir, "NoHat", pictureBox2, @@ -80,10 +79,10 @@ public partial class CharacterCustomizationCompact : Form { if (Directory.Exists(GlobalPaths.hatdir)) { - GlobalVars.UserCustomization.Hat3 = listBox3.SelectedItem.ToString(); + GlobalVars.UserCustomization.SaveSetting("Hat3", listBox3.SelectedItem.ToString()); characterCustomizationForm.ChangeItem( - GlobalVars.UserCustomization.Hat3, + GlobalVars.UserCustomization.ReadSetting("Hat3"), GlobalPaths.hatdir, "NoHat", pictureBox3, @@ -139,10 +138,10 @@ public partial class CharacterCustomizationCompact : Form } } listBox4.SelectedItem = previtem; - GlobalVars.UserCustomization.Face = previtem; + GlobalVars.UserCustomization.SaveSetting("Face", previtem); characterCustomizationForm.ChangeItem( - GlobalVars.UserCustomization.Face, + GlobalVars.UserCustomization.ReadSetting("Face"), GlobalPaths.facedir, "DefaultFace", pictureBox4, @@ -188,16 +187,16 @@ public partial class CharacterCustomizationCompact : Form if (!string.IsNullOrWhiteSpace(FaceIDBox.Text)) { - GlobalVars.UserCustomization.Face = characterCustomizationForm.Custom_Face_URL + FaceIDBox.Text; + GlobalVars.UserCustomization.SaveSetting("Face", characterCustomizationForm.Custom_Face_URL + FaceIDBox.Text); FaceIDBox.Focus(); } else { - GlobalVars.UserCustomization.Face = listBox4.SelectedItem.ToString(); + GlobalVars.UserCustomization.SaveSetting("Face", listBox4.SelectedItem.ToString()); } characterCustomizationForm.ChangeItem( - GlobalVars.UserCustomization.Face, + GlobalVars.UserCustomization.ReadSetting("Face"), GlobalPaths.facedir, "DefaultFace", pictureBox4, @@ -220,9 +219,9 @@ public partial class CharacterCustomizationCompact : Form if (!string.IsNullOrWhiteSpace(FaceIDBox.Text)) { - GlobalVars.UserCustomization.Face = characterCustomizationForm.Custom_Face_URL + FaceIDBox.Text; + GlobalVars.UserCustomization.SaveSetting("Face", characterCustomizationForm.Custom_Face_URL + FaceIDBox.Text); characterCustomizationForm.ChangeItem( - GlobalVars.UserCustomization.Face, + GlobalVars.UserCustomization.ReadSetting("Face"), GlobalPaths.facedir, "DefaultFace", pictureBox4, @@ -252,10 +251,10 @@ public partial class CharacterCustomizationCompact : Form } } listBox5.SelectedItem = previtem; - GlobalVars.UserCustomization.TShirt = previtem; + GlobalVars.UserCustomization.SaveSetting("TShirt", previtem); characterCustomizationForm.ChangeItem( - GlobalVars.UserCustomization.TShirt, + GlobalVars.UserCustomization.ReadSetting("TShirt"), GlobalPaths.tshirtdir, "NoTShirt", pictureBox5, @@ -301,16 +300,16 @@ public partial class CharacterCustomizationCompact : Form if (!string.IsNullOrWhiteSpace(TShirtsIDBox.Text)) { - GlobalVars.UserCustomization.TShirt = characterCustomizationForm.Custom_T_Shirt_URL + TShirtsIDBox.Text; + GlobalVars.UserCustomization.SaveSetting("TShirt", characterCustomizationForm.Custom_T_Shirt_URL + TShirtsIDBox.Text); TShirtsIDBox.Focus(); } else { - GlobalVars.UserCustomization.TShirt = listBox5.SelectedItem.ToString(); + GlobalVars.UserCustomization.SaveSetting("TShirt", listBox5.SelectedItem.ToString()); } characterCustomizationForm.ChangeItem( - GlobalVars.UserCustomization.TShirt, + GlobalVars.UserCustomization.ReadSetting("TShirt"), GlobalPaths.tshirtdir, "NoTShirt", pictureBox5, @@ -333,9 +332,9 @@ public partial class CharacterCustomizationCompact : Form if (!string.IsNullOrWhiteSpace(TShirtsIDBox.Text)) { - GlobalVars.UserCustomization.TShirt = characterCustomizationForm.Custom_T_Shirt_URL + TShirtsIDBox.Text; + GlobalVars.UserCustomization.SaveSetting("TShirt", characterCustomizationForm.Custom_T_Shirt_URL + TShirtsIDBox.Text); characterCustomizationForm.ChangeItem( - GlobalVars.UserCustomization.TShirt, + GlobalVars.UserCustomization.ReadSetting("TShirt"), GlobalPaths.tshirtdir, "NoTShirt", pictureBox5, @@ -364,10 +363,10 @@ public partial class CharacterCustomizationCompact : Form } } listBox6.SelectedItem = previtem; - GlobalVars.UserCustomization.Shirt = previtem; + GlobalVars.UserCustomization.SaveSetting("Shirt", previtem); characterCustomizationForm.ChangeItem( - GlobalVars.UserCustomization.Shirt, + GlobalVars.UserCustomization.ReadSetting("Shirt"), GlobalPaths.shirtdir, "NoShirt", pictureBox6, @@ -413,16 +412,16 @@ public partial class CharacterCustomizationCompact : Form if (!string.IsNullOrWhiteSpace(ShirtsIDBox.Text)) { - GlobalVars.UserCustomization.Shirt = characterCustomizationForm.Custom_Shirt_URL + ShirtsIDBox.Text; + GlobalVars.UserCustomization.SaveSetting("Shirt", characterCustomizationForm.Custom_Shirt_URL + ShirtsIDBox.Text); ShirtsIDBox.Focus(); } else { - GlobalVars.UserCustomization.Shirt = listBox6.SelectedItem.ToString(); + GlobalVars.UserCustomization.SaveSetting("Shirt", listBox6.SelectedItem.ToString()); } characterCustomizationForm.ChangeItem( - GlobalVars.UserCustomization.Shirt, + GlobalVars.UserCustomization.ReadSetting("Shirt"), GlobalPaths.shirtdir, "NoShirt", pictureBox6, @@ -445,9 +444,9 @@ public partial class CharacterCustomizationCompact : Form if (!string.IsNullOrWhiteSpace(ShirtsIDBox.Text)) { - GlobalVars.UserCustomization.Shirt = characterCustomizationForm.Custom_Shirt_URL + ShirtsIDBox.Text; + GlobalVars.UserCustomization.SaveSetting("Shirt", characterCustomizationForm.Custom_Shirt_URL + ShirtsIDBox.Text); characterCustomizationForm.ChangeItem( - GlobalVars.UserCustomization.Shirt, + GlobalVars.UserCustomization.ReadSetting("Shirt"), GlobalPaths.shirtdir, "NoShirt", pictureBox6, @@ -476,10 +475,10 @@ public partial class CharacterCustomizationCompact : Form } } listBox7.SelectedItem = previtem; - GlobalVars.UserCustomization.Pants = previtem; + GlobalVars.UserCustomization.SaveSetting("Pants", previtem); characterCustomizationForm.ChangeItem( - GlobalVars.UserCustomization.Pants, + GlobalVars.UserCustomization.ReadSetting("Pants"), GlobalPaths.pantsdir, "NoPants", pictureBox7, @@ -525,16 +524,16 @@ public partial class CharacterCustomizationCompact : Form if (!string.IsNullOrWhiteSpace(PantsIDBox.Text)) { - GlobalVars.UserCustomization.Pants = characterCustomizationForm.Custom_Pants_URL + PantsIDBox.Text; + GlobalVars.UserCustomization.SaveSetting("Pants", characterCustomizationForm.Custom_Pants_URL + PantsIDBox.Text); PantsIDBox.Focus(); } else { - GlobalVars.UserCustomization.Pants = listBox7.SelectedItem.ToString(); + GlobalVars.UserCustomization.SaveSetting("Pants", listBox7.SelectedItem.ToString()); } characterCustomizationForm.ChangeItem( - GlobalVars.UserCustomization.Pants, + GlobalVars.UserCustomization.ReadSetting("Pants"), GlobalPaths.pantsdir, "NoPants", pictureBox7, @@ -557,9 +556,9 @@ public partial class CharacterCustomizationCompact : Form if (!string.IsNullOrWhiteSpace(PantsIDBox.Text)) { - GlobalVars.UserCustomization.Pants = characterCustomizationForm.Custom_Pants_URL + PantsIDBox.Text; + GlobalVars.UserCustomization.SaveSetting("Pants", characterCustomizationForm.Custom_Pants_URL + PantsIDBox.Text); characterCustomizationForm.ChangeItem( - GlobalVars.UserCustomization.Pants, + GlobalVars.UserCustomization.ReadSetting("Pants"), GlobalPaths.pantsdir, "NoPants", pictureBox7, @@ -578,10 +577,10 @@ public partial class CharacterCustomizationCompact : Form { if (Directory.Exists(GlobalPaths.headdir)) { - GlobalVars.UserCustomization.Head = listBox8.SelectedItem.ToString(); + GlobalVars.UserCustomization.SaveSetting("Head", listBox8.SelectedItem.ToString()); characterCustomizationForm.ChangeItem( - GlobalVars.UserCustomization.Head, + GlobalVars.UserCustomization.ReadSetting("Head"), GlobalPaths.headdir, "DefaultHead", pictureBox8, @@ -616,10 +615,10 @@ public partial class CharacterCustomizationCompact : Form { if (Directory.Exists(GlobalPaths.extradir)) { - GlobalVars.UserCustomization.Extra = listBox9.SelectedItem.ToString(); + GlobalVars.UserCustomization.SaveSetting("Extra", listBox9.SelectedItem.ToString()); characterCustomizationForm.ChangeItem( - GlobalVars.UserCustomization.Extra, + GlobalVars.UserCustomization.ReadSetting("Extra"), GlobalPaths.extradir, "NoExtra", pictureBox9, @@ -628,17 +627,17 @@ public partial class CharacterCustomizationCompact : Form false ); - if (GlobalVars.UserCustomization.ShowHatsInExtra) + if (GlobalVars.UserCustomization.ReadSettingBool("ShowHatsInExtra")) { characterCustomizationForm.ChangeItem( - GlobalVars.UserCustomization.Extra, + GlobalVars.UserCustomization.ReadSetting("Extra"), GlobalPaths.hatdir, "NoHat", pictureBox9, textBox10, listBox9, false, - GlobalVars.UserCustomization.ShowHatsInExtra + GlobalVars.UserCustomization.ReadSettingBool("ShowHatsInExtra") ); } } @@ -664,11 +663,11 @@ public partial class CharacterCustomizationCompact : Form void CheckBox1CheckedChanged(object sender, EventArgs e) { - GlobalVars.UserCustomization.ShowHatsInExtra = checkBox1.Checked; + GlobalVars.UserCustomization.SaveSettingBool("ShowHatsInExtra", checkBox1.Checked); listBox9.Items.Clear(); characterCustomizationForm.ChangeItem( - GlobalVars.UserCustomization.Extra, + GlobalVars.UserCustomization.ReadSetting("Extra"), GlobalPaths.extradir, "NoExtra", pictureBox9, @@ -677,17 +676,17 @@ public partial class CharacterCustomizationCompact : Form true ); - if (GlobalVars.UserCustomization.ShowHatsInExtra) + if (GlobalVars.UserCustomization.ReadSettingBool("ShowHatsInExtra")) { characterCustomizationForm.ChangeItem( - GlobalVars.UserCustomization.Extra, + GlobalVars.UserCustomization.ReadSetting("Extra"), GlobalPaths.hatdir, "NoHat", pictureBox9, textBox10, listBox9, true, - GlobalVars.UserCustomization.ShowHatsInExtra + GlobalVars.UserCustomization.ReadSettingBool("ShowHatsInExtra") ); } else @@ -784,32 +783,32 @@ public partial class CharacterCustomizationCompact : Form void Button52Click(object sender, EventArgs e) { IconURLBox.Text = ""; - GlobalVars.UserCustomization.Icon = "BC"; - label5.Text = GlobalVars.UserCustomization.Icon; + GlobalVars.UserCustomization.SaveSetting("Icon", "BC"); + label5.Text = GlobalVars.UserCustomization.ReadSetting("Icon"); characterCustomizationForm.SaveOutfit(false); } void Button53Click(object sender, EventArgs e) { IconURLBox.Text = ""; - GlobalVars.UserCustomization.Icon = "TBC"; - label5.Text = GlobalVars.UserCustomization.Icon; + GlobalVars.UserCustomization.SaveSetting("Icon", "TBC"); + label5.Text = GlobalVars.UserCustomization.ReadSetting("Icon"); characterCustomizationForm.SaveOutfit(false); } void Button54Click(object sender, EventArgs e) { IconURLBox.Text = ""; - GlobalVars.UserCustomization.Icon = "OBC"; - label5.Text = GlobalVars.UserCustomization.Icon; + GlobalVars.UserCustomization.SaveSetting("Icon", "OBC"); + label5.Text = GlobalVars.UserCustomization.ReadSetting("Icon"); characterCustomizationForm.SaveOutfit(false); } void Button55Click(object sender, EventArgs e) { IconURLBox.Text = ""; - GlobalVars.UserCustomization.Icon = "NBC"; - label5.Text = GlobalVars.UserCustomization.Icon; + GlobalVars.UserCustomization.SaveSetting("Icon", "NBC"); + label5.Text = GlobalVars.UserCustomization.ReadSetting("Icon"); characterCustomizationForm.SaveOutfit(false); } @@ -841,7 +840,7 @@ public partial class CharacterCustomizationCompact : Form void TextBox1TextChanged(object sender, EventArgs e) { - GlobalVars.UserCustomization.CharacterID = textBox1.Text; + GlobalVars.UserCustomization.SaveSetting("CharacterID", textBox1.Text); characterCustomizationForm.SaveOutfit(false); } diff --git a/Novetus/NovetusCore/CharCustom/Forms/Extended/CharacterCustomizationExtended.cs b/Novetus/NovetusCore/CharCustom/Forms/Extended/CharacterCustomizationExtended.cs index 12922a4..d3c942a 100644 --- a/Novetus/NovetusCore/CharCustom/Forms/Extended/CharacterCustomizationExtended.cs +++ b/Novetus/NovetusCore/CharCustom/Forms/Extended/CharacterCustomizationExtended.cs @@ -45,15 +45,14 @@ public partial class CharacterCustomizationExtended : Form } #region Hats - void ListBox1SelectedIndexChanged(object sender, EventArgs e) { if (Directory.Exists(GlobalPaths.hatdir)) { - GlobalVars.UserCustomization.Hat1 = listBox1.SelectedItem.ToString(); + GlobalVars.UserCustomization.SaveSetting("Hat1", listBox1.SelectedItem.ToString()); characterCustomizationForm.ChangeItem( - GlobalVars.UserCustomization.Hat1, + GlobalVars.UserCustomization.ReadSetting("Hat1"), GlobalPaths.hatdir, "NoHat", pictureBox1, @@ -68,10 +67,10 @@ public partial class CharacterCustomizationExtended : Form { if (Directory.Exists(GlobalPaths.hatdir)) { - GlobalVars.UserCustomization.Hat2 = listBox2.SelectedItem.ToString(); + GlobalVars.UserCustomization.SaveSetting("Hat2", listBox2.SelectedItem.ToString()); characterCustomizationForm.ChangeItem( - GlobalVars.UserCustomization.Hat2, + GlobalVars.UserCustomization.ReadSetting("Hat1"), GlobalPaths.hatdir, "NoHat", pictureBox2, @@ -86,10 +85,10 @@ public partial class CharacterCustomizationExtended : Form { if (Directory.Exists(GlobalPaths.hatdir)) { - GlobalVars.UserCustomization.Hat3 = listBox3.SelectedItem.ToString(); + GlobalVars.UserCustomization.SaveSetting("Hat3", listBox3.SelectedItem.ToString()); characterCustomizationForm.ChangeItem( - GlobalVars.UserCustomization.Hat3, + GlobalVars.UserCustomization.ReadSetting("Hat3"), GlobalPaths.hatdir, "NoHat", pictureBox3, @@ -145,10 +144,10 @@ public partial class CharacterCustomizationExtended : Form } } listBox4.SelectedItem = previtem; - GlobalVars.UserCustomization.Face = previtem; + GlobalVars.UserCustomization.SaveSetting("Face", previtem); characterCustomizationForm.ChangeItem( - GlobalVars.UserCustomization.Face, + GlobalVars.UserCustomization.ReadSetting("Face"), GlobalPaths.facedir, "DefaultFace", pictureBox4, @@ -194,16 +193,16 @@ public partial class CharacterCustomizationExtended : Form if (!string.IsNullOrWhiteSpace(FaceIDBox.Text)) { - GlobalVars.UserCustomization.Face = characterCustomizationForm.Custom_Face_URL + FaceIDBox.Text; + GlobalVars.UserCustomization.SaveSetting("Face", characterCustomizationForm.Custom_Face_URL + FaceIDBox.Text); FaceIDBox.Focus(); } else { - GlobalVars.UserCustomization.Face = listBox4.SelectedItem.ToString(); + GlobalVars.UserCustomization.SaveSetting("Face", listBox4.SelectedItem.ToString()); } characterCustomizationForm.ChangeItem( - GlobalVars.UserCustomization.Face, + GlobalVars.UserCustomization.ReadSetting("Face"), GlobalPaths.facedir, "DefaultFace", pictureBox4, @@ -226,9 +225,9 @@ public partial class CharacterCustomizationExtended : Form if (!string.IsNullOrWhiteSpace(FaceIDBox.Text)) { - GlobalVars.UserCustomization.Face = characterCustomizationForm.Custom_Face_URL + FaceIDBox.Text; + GlobalVars.UserCustomization.SaveSetting("Face", characterCustomizationForm.Custom_Face_URL + FaceIDBox.Text); characterCustomizationForm.ChangeItem( - GlobalVars.UserCustomization.Face, + GlobalVars.UserCustomization.ReadSetting("Face"), GlobalPaths.facedir, "DefaultFace", pictureBox4, @@ -258,10 +257,10 @@ public partial class CharacterCustomizationExtended : Form } } listBox5.SelectedItem = previtem; - GlobalVars.UserCustomization.TShirt = previtem; + GlobalVars.UserCustomization.SaveSetting("TShirt", previtem); characterCustomizationForm.ChangeItem( - GlobalVars.UserCustomization.TShirt, + GlobalVars.UserCustomization.ReadSetting("TShirt"), GlobalPaths.tshirtdir, "NoTShirt", pictureBox5, @@ -307,16 +306,16 @@ public partial class CharacterCustomizationExtended : Form if (!string.IsNullOrWhiteSpace(TShirtsIDBox.Text)) { - GlobalVars.UserCustomization.TShirt = characterCustomizationForm.Custom_T_Shirt_URL + TShirtsIDBox.Text; + GlobalVars.UserCustomization.SaveSetting("TShirt", characterCustomizationForm.Custom_T_Shirt_URL + TShirtsIDBox.Text); TShirtsIDBox.Focus(); } else { - GlobalVars.UserCustomization.TShirt = listBox5.SelectedItem.ToString(); + GlobalVars.UserCustomization.SaveSetting("TShirt", listBox5.SelectedItem.ToString()); } characterCustomizationForm.ChangeItem( - GlobalVars.UserCustomization.TShirt, + GlobalVars.UserCustomization.ReadSetting("TShirt"), GlobalPaths.tshirtdir, "NoTShirt", pictureBox5, @@ -339,9 +338,9 @@ public partial class CharacterCustomizationExtended : Form if (!string.IsNullOrWhiteSpace(TShirtsIDBox.Text)) { - GlobalVars.UserCustomization.TShirt = characterCustomizationForm.Custom_T_Shirt_URL + TShirtsIDBox.Text; + GlobalVars.UserCustomization.SaveSetting("TShirt", characterCustomizationForm.Custom_T_Shirt_URL + TShirtsIDBox.Text); characterCustomizationForm.ChangeItem( - GlobalVars.UserCustomization.TShirt, + GlobalVars.UserCustomization.ReadSetting("TShirt"), GlobalPaths.tshirtdir, "NoTShirt", pictureBox5, @@ -370,10 +369,10 @@ public partial class CharacterCustomizationExtended : Form } } listBox6.SelectedItem = previtem; - GlobalVars.UserCustomization.Shirt = previtem; + GlobalVars.UserCustomization.SaveSetting("Shirt", previtem); characterCustomizationForm.ChangeItem( - GlobalVars.UserCustomization.Shirt, + GlobalVars.UserCustomization.ReadSetting("Shirt"), GlobalPaths.shirtdir, "NoShirt", pictureBox6, @@ -419,16 +418,16 @@ public partial class CharacterCustomizationExtended : Form if (!string.IsNullOrWhiteSpace(ShirtsIDBox.Text)) { - GlobalVars.UserCustomization.Shirt = characterCustomizationForm.Custom_Shirt_URL + ShirtsIDBox.Text; + GlobalVars.UserCustomization.SaveSetting("Shirt", characterCustomizationForm.Custom_Shirt_URL + ShirtsIDBox.Text); ShirtsIDBox.Focus(); } else { - GlobalVars.UserCustomization.Shirt = listBox6.SelectedItem.ToString(); + GlobalVars.UserCustomization.SaveSetting("Shirt", listBox6.SelectedItem.ToString()); } characterCustomizationForm.ChangeItem( - GlobalVars.UserCustomization.Shirt, + GlobalVars.UserCustomization.ReadSetting("Shirt"), GlobalPaths.shirtdir, "NoShirt", pictureBox6, @@ -451,9 +450,9 @@ public partial class CharacterCustomizationExtended : Form if (!string.IsNullOrWhiteSpace(ShirtsIDBox.Text)) { - GlobalVars.UserCustomization.Shirt = characterCustomizationForm.Custom_Shirt_URL + ShirtsIDBox.Text; + GlobalVars.UserCustomization.SaveSetting("Shirt", characterCustomizationForm.Custom_Shirt_URL + ShirtsIDBox.Text); characterCustomizationForm.ChangeItem( - GlobalVars.UserCustomization.Shirt, + GlobalVars.UserCustomization.ReadSetting("Shirt"), GlobalPaths.shirtdir, "NoShirt", pictureBox6, @@ -482,10 +481,10 @@ public partial class CharacterCustomizationExtended : Form } } listBox7.SelectedItem = previtem; - GlobalVars.UserCustomization.Pants = previtem; + GlobalVars.UserCustomization.SaveSetting("Pants", previtem); characterCustomizationForm.ChangeItem( - GlobalVars.UserCustomization.Pants, + GlobalVars.UserCustomization.ReadSetting("Pants"), GlobalPaths.pantsdir, "NoPants", pictureBox7, @@ -531,16 +530,16 @@ public partial class CharacterCustomizationExtended : Form if (!string.IsNullOrWhiteSpace(PantsIDBox.Text)) { - GlobalVars.UserCustomization.Pants = characterCustomizationForm.Custom_Pants_URL + PantsIDBox.Text; + GlobalVars.UserCustomization.SaveSetting("Pants", characterCustomizationForm.Custom_Pants_URL + PantsIDBox.Text); PantsIDBox.Focus(); } else { - GlobalVars.UserCustomization.Pants = listBox7.SelectedItem.ToString(); + GlobalVars.UserCustomization.SaveSetting("Pants", listBox7.SelectedItem.ToString()); } characterCustomizationForm.ChangeItem( - GlobalVars.UserCustomization.Pants, + GlobalVars.UserCustomization.ReadSetting("Pants"), GlobalPaths.pantsdir, "NoPants", pictureBox7, @@ -563,9 +562,9 @@ public partial class CharacterCustomizationExtended : Form if (!string.IsNullOrWhiteSpace(PantsIDBox.Text)) { - GlobalVars.UserCustomization.Pants = characterCustomizationForm.Custom_Pants_URL + PantsIDBox.Text; + GlobalVars.UserCustomization.SaveSetting("Pants", characterCustomizationForm.Custom_Pants_URL + PantsIDBox.Text); characterCustomizationForm.ChangeItem( - GlobalVars.UserCustomization.Pants, + GlobalVars.UserCustomization.ReadSetting("Pants"), GlobalPaths.pantsdir, "NoPants", pictureBox7, @@ -584,10 +583,10 @@ public partial class CharacterCustomizationExtended : Form { if (Directory.Exists(GlobalPaths.headdir)) { - GlobalVars.UserCustomization.Head = listBox8.SelectedItem.ToString(); + GlobalVars.UserCustomization.SaveSetting("Head", listBox8.SelectedItem.ToString()); characterCustomizationForm.ChangeItem( - GlobalVars.UserCustomization.Head, + GlobalVars.UserCustomization.ReadSetting("Head"), GlobalPaths.headdir, "DefaultHead", pictureBox8, @@ -622,10 +621,10 @@ public partial class CharacterCustomizationExtended : Form { if (Directory.Exists(GlobalPaths.extradir)) { - GlobalVars.UserCustomization.Extra = listBox9.SelectedItem.ToString(); + GlobalVars.UserCustomization.SaveSetting("Extra", listBox9.SelectedItem.ToString()); characterCustomizationForm.ChangeItem( - GlobalVars.UserCustomization.Extra, + GlobalVars.UserCustomization.ReadSetting("Extra"), GlobalPaths.extradir, "NoExtra", pictureBox9, @@ -634,17 +633,17 @@ public partial class CharacterCustomizationExtended : Form false ); - if (GlobalVars.UserCustomization.ShowHatsInExtra) + if (GlobalVars.UserCustomization.ReadSettingBool("ShowHatsInExtra")) { characterCustomizationForm.ChangeItem( - GlobalVars.UserCustomization.Extra, + GlobalVars.UserCustomization.ReadSetting("Extra"), GlobalPaths.hatdir, "NoHat", pictureBox9, textBox10, listBox9, false, - GlobalVars.UserCustomization.ShowHatsInExtra + GlobalVars.UserCustomization.ReadSettingBool("ShowHatsInExtra") ); } } @@ -670,11 +669,11 @@ public partial class CharacterCustomizationExtended : Form void CheckBox1CheckedChanged(object sender, EventArgs e) { - GlobalVars.UserCustomization.ShowHatsInExtra = checkBox1.Checked; + GlobalVars.UserCustomization.SaveSettingBool("ShowHatsInExtra", checkBox1.Checked); listBox9.Items.Clear(); characterCustomizationForm.ChangeItem( - GlobalVars.UserCustomization.Extra, + GlobalVars.UserCustomization.ReadSetting("Extra"), GlobalPaths.extradir, "NoExtra", pictureBox9, @@ -683,17 +682,17 @@ public partial class CharacterCustomizationExtended : Form true ); - if (GlobalVars.UserCustomization.ShowHatsInExtra) + if (GlobalVars.UserCustomization.ReadSettingBool("ShowHatsInExtra")) { characterCustomizationForm.ChangeItem( - GlobalVars.UserCustomization.Extra, + GlobalVars.UserCustomization.ReadSetting("Extra"), GlobalPaths.hatdir, "NoHat", pictureBox9, textBox10, listBox9, true, - GlobalVars.UserCustomization.ShowHatsInExtra + GlobalVars.UserCustomization.ReadSettingBool("ShowHatsInExtra") ); } else @@ -784,38 +783,38 @@ public partial class CharacterCustomizationExtended : Form { characterCustomizationForm.ApplyPreset(9, 194, 9, 9, 119, 119); } -#endregion + #endregion -#region Icon + #region Icon void Button52Click(object sender, EventArgs e) { IconURLBox.Text = ""; - GlobalVars.UserCustomization.Icon = "BC"; - label5.Text = GlobalVars.UserCustomization.Icon; + GlobalVars.UserCustomization.SaveSetting("Icon", "BC"); + label5.Text = GlobalVars.UserCustomization.ReadSetting("Icon"); characterCustomizationForm.SaveOutfit(false); } void Button53Click(object sender, EventArgs e) { IconURLBox.Text = ""; - GlobalVars.UserCustomization.Icon = "TBC"; - label5.Text = GlobalVars.UserCustomization.Icon; + GlobalVars.UserCustomization.SaveSetting("Icon", "TBC"); + label5.Text = GlobalVars.UserCustomization.ReadSetting("Icon"); characterCustomizationForm.SaveOutfit(false); } void Button54Click(object sender, EventArgs e) { IconURLBox.Text = ""; - GlobalVars.UserCustomization.Icon = "OBC"; - label5.Text = GlobalVars.UserCustomization.Icon; + GlobalVars.UserCustomization.SaveSetting("Icon", "OBC"); + label5.Text = GlobalVars.UserCustomization.ReadSetting("Icon"); characterCustomizationForm.SaveOutfit(false); } void Button55Click(object sender, EventArgs e) { IconURLBox.Text = ""; - GlobalVars.UserCustomization.Icon = "NBC"; - label5.Text = GlobalVars.UserCustomization.Icon; + GlobalVars.UserCustomization.SaveSetting("Icon", "NBC"); + label5.Text = GlobalVars.UserCustomization.ReadSetting("Icon"); characterCustomizationForm.SaveOutfit(false); } @@ -828,9 +827,9 @@ public partial class CharacterCustomizationExtended : Form { characterCustomizationForm.LoadRemoteIcon(); } -#endregion + #endregion -#region Navigation + #region Navigation (Extended) private void button72_Click(object sender, EventArgs e) { tabControl1.SelectedTab = tabPage1; @@ -909,7 +908,7 @@ public partial class CharacterCustomizationExtended : Form void TextBox1TextChanged(object sender, EventArgs e) { - GlobalVars.UserCustomization.CharacterID = textBox1.Text; + GlobalVars.UserCustomization.SaveSetting("CharacterID", textBox1.Text); characterCustomizationForm.SaveOutfit(false); } @@ -920,7 +919,7 @@ public partial class CharacterCustomizationExtended : Form private void label9_Paint(object sender, PaintEventArgs e) { - if (GlobalVars.UserConfiguration.LauncherStyle == Settings.Style.Stylish) + if (GlobalVars.UserConfiguration.ReadSettingInt("LauncherStyle") == (int)Settings.Style.Stylish) { Util.DrawBorderSimple(e.Graphics, label9.DisplayRectangle, Color.White, ButtonBorderStyle.Solid, 1); } @@ -928,7 +927,7 @@ public partial class CharacterCustomizationExtended : Form private void panel1_Paint(object sender, PaintEventArgs e) { - if (GlobalVars.UserConfiguration.LauncherStyle == Settings.Style.Stylish) + if (GlobalVars.UserConfiguration.ReadSettingInt("LauncherStyle") == (int)Settings.Style.Stylish) { Util.DrawBorderSimple(e.Graphics, panel1.DisplayRectangle, Color.Black, ButtonBorderStyle.Solid, 1); } diff --git a/Novetus/NovetusCore/Classes/IDiscordRPC.cs b/Novetus/NovetusCore/Classes/IDiscordRPC.cs index e3e7ece..f9357e3 100644 --- a/Novetus/NovetusCore/Classes/IDiscordRPC.cs +++ b/Novetus/NovetusCore/Classes/IDiscordRPC.cs @@ -128,7 +128,7 @@ namespace Novetus.Core public static void StartDiscord() { - if (GlobalVars.UserConfiguration.DiscordPresence) + if (GlobalVars.UserConfiguration.ReadSettingBool("DiscordRichPresence")) { GlobalVars.handlers = new IDiscordRPC.EventHandlers(); GlobalVars.handlers.readyCallback = ReadyCallback; diff --git a/Novetus/NovetusCore/Classes/INIFile.cs b/Novetus/NovetusCore/Classes/INIFile.cs index 02598ba..0d74efd 100644 --- a/Novetus/NovetusCore/Classes/INIFile.cs +++ b/Novetus/NovetusCore/Classes/INIFile.cs @@ -26,12 +26,17 @@ namespace Novetus.Core /// INIFile Constructor. /// /// - public INIFile(string INIPath) + public INIFile(string INIPath, bool createNewFile = true) { path = INIPath; - if (!File.Exists(path)) + if (createNewFile) { + if (File.Exists(path)) + { + Util.FixedFileDelete(path); + } + File.Create(path).Close(); } } diff --git a/Novetus/NovetusCore/Classes/Script.cs b/Novetus/NovetusCore/Classes/Script.cs index ee0d47b..dccdbd6 100644 --- a/Novetus/NovetusCore/Classes/Script.cs +++ b/Novetus/NovetusCore/Classes/Script.cs @@ -16,7 +16,7 @@ namespace Novetus.Core { public virtual string Name() { return "Unnamed Object"; } public virtual string Version() { return "1.0.0"; } - public virtual string Author() { return GlobalVars.UserConfiguration.PlayerName; } + public virtual string Author() { return GlobalVars.UserConfiguration.ReadSetting("PlayerName"); } public virtual string FullInfoString() { return (Name() + " v" + Version() + " by " + Author()); } public virtual void OnExtensionLoad() { } public virtual void OnExtensionUnload() { } diff --git a/Novetus/NovetusCore/Classes/WebProxy.cs b/Novetus/NovetusCore/Classes/WebProxy.cs index caae2c0..80a7fbe 100644 --- a/Novetus/NovetusCore/Classes/WebProxy.cs +++ b/Novetus/NovetusCore/Classes/WebProxy.cs @@ -39,7 +39,7 @@ namespace Novetus.Core public void DoSetup() { - if (GlobalVars.UserConfiguration.WebProxyInitialSetupRequired) + if (GlobalVars.UserConfiguration.ReadSettingBool("WebProxyInitialSetupRequired")) { string text = "Would you like to enable the Novetus web proxy?\n\n" + "A web proxy redirects web traffic to a different location and in some cases can act as a gateway to different sites. Novetus uses the web proxy for additional client features and asset redirection.\n\n" + @@ -55,7 +55,7 @@ namespace Novetus.Core switch (result) { case DialogResult.Yes: - GlobalVars.UserConfiguration.WebProxyEnabled = true; + GlobalVars.UserConfiguration.SaveSettingBool("WebProxyEnabled", true); Start(); break; case DialogResult.No: @@ -63,12 +63,11 @@ namespace Novetus.Core break; } - GlobalVars.UserConfiguration.WebProxyInitialSetupRequired = false; - FileManagement.Config(GlobalPaths.ConfigDir + "\\" + GlobalPaths.ConfigName, true); + GlobalVars.UserConfiguration.SaveSettingBool("WebProxyInitialSetupRequired", false); } else { - if (GlobalVars.UserConfiguration.WebProxyEnabled) + if (GlobalVars.UserConfiguration.ReadSettingBool("WebProxyEnabled")) { Start(); } diff --git a/Novetus/NovetusCore/StorageAndFunctions/ClientManagement.cs b/Novetus/NovetusCore/StorageAndFunctions/ClientManagement.cs index edb05dc..e36301a 100644 --- a/Novetus/NovetusCore/StorageAndFunctions/ClientManagement.cs +++ b/Novetus/NovetusCore/StorageAndFunctions/ClientManagement.cs @@ -19,7 +19,7 @@ namespace Novetus.Core { public static void ReadClientValues(bool initial = false) { - ReadClientValues(GlobalVars.UserConfiguration.SelectedClient, initial); + ReadClientValues(GlobalVars.UserConfiguration.ReadSetting("SelectedClient"), initial); } public static void ReadClientValues(string ClientName, bool initial = false) @@ -186,7 +186,7 @@ namespace Novetus.Core throw clientNotFoundEX; }*/ - string desc = "This client information file for '" + GlobalVars.UserConfiguration.SelectedClient + + string desc = "This client information file for '" + GlobalVars.UserConfiguration.ReadSetting("SelectedClient") + "' was pre-generated by Novetus for your convienence. You will need to load this clientinfo.nov file into the Client SDK for additional options. " + LoremIpsum(1, 128, 1, 6, 1); @@ -337,20 +337,20 @@ namespace Novetus.Core string mapname = ""; if (GlobalVars.GameOpened != ScriptType.Client) { - mapname = GlobalVars.UserConfiguration.Map; + mapname = GlobalVars.UserConfiguration.ReadSetting("Map"); } - UpdateRichPresence(state, GlobalVars.UserConfiguration.SelectedClient, mapname, initial); + UpdateRichPresence(state, GlobalVars.UserConfiguration.ReadSetting("SelectedClient"), mapname, initial); } public static void UpdateRichPresence(GlobalVars.LauncherState state, string mapname, bool initial = false) { - UpdateRichPresence(state, GlobalVars.UserConfiguration.SelectedClient, mapname, initial); + UpdateRichPresence(state, GlobalVars.UserConfiguration.ReadSetting("SelectedClient"), mapname, initial); } public static void UpdateRichPresence(GlobalVars.LauncherState state, string clientname, string mapname, bool initial = false) { - if (GlobalVars.UserConfiguration.DiscordPresence) + if (GlobalVars.UserConfiguration.ReadSettingBool("DiscordRichPresence")) { if (initial) { @@ -367,49 +367,49 @@ namespace Novetus.Core GlobalVars.presence.smallImageKey = GlobalVars.image_inlauncher; GlobalVars.presence.state = "In Launcher"; GlobalVars.presence.details = "Selected " + clientname; - GlobalVars.presence.largeImageText = GlobalVars.UserConfiguration.PlayerName + " | Novetus " + GlobalVars.ProgramInformation.Version; + GlobalVars.presence.largeImageText = GlobalVars.UserConfiguration.ReadSetting("PlayerName") + " | Novetus " + GlobalVars.ProgramInformation.Version; GlobalVars.presence.smallImageText = "In Launcher"; break; case GlobalVars.LauncherState.InMPGame: GlobalVars.presence.smallImageKey = GlobalVars.image_ingame; GlobalVars.presence.details = ValidMapname; GlobalVars.presence.state = "In " + clientname + " Multiplayer Game"; - GlobalVars.presence.largeImageText = GlobalVars.UserConfiguration.PlayerName + " | Novetus " + GlobalVars.ProgramInformation.Version; + GlobalVars.presence.largeImageText = GlobalVars.UserConfiguration.ReadSetting("PlayerName") + " | Novetus " + GlobalVars.ProgramInformation.Version; GlobalVars.presence.smallImageText = "In " + clientname + " Multiplayer Game"; break; case GlobalVars.LauncherState.InSoloGame: GlobalVars.presence.smallImageKey = GlobalVars.image_ingame; GlobalVars.presence.details = ValidMapname; GlobalVars.presence.state = "In " + clientname + " Solo Game"; - GlobalVars.presence.largeImageText = GlobalVars.UserConfiguration.PlayerName + " | Novetus " + GlobalVars.ProgramInformation.Version; + GlobalVars.presence.largeImageText = GlobalVars.UserConfiguration.ReadSetting("PlayerName") + " | Novetus " + GlobalVars.ProgramInformation.Version; GlobalVars.presence.smallImageText = "In " + clientname + " Solo Game"; break; case GlobalVars.LauncherState.InStudio: GlobalVars.presence.smallImageKey = GlobalVars.image_instudio; GlobalVars.presence.details = ValidMapname; GlobalVars.presence.state = "In " + clientname + " Studio"; - GlobalVars.presence.largeImageText = GlobalVars.UserConfiguration.PlayerName + " | Novetus " + GlobalVars.ProgramInformation.Version; + GlobalVars.presence.largeImageText = GlobalVars.UserConfiguration.ReadSetting("PlayerName") + " | Novetus " + GlobalVars.ProgramInformation.Version; GlobalVars.presence.smallImageText = "In " + clientname + " Studio"; break; case GlobalVars.LauncherState.InCustomization: GlobalVars.presence.smallImageKey = GlobalVars.image_incustomization; - GlobalVars.presence.details = "Customizing " + GlobalVars.UserConfiguration.PlayerName; + GlobalVars.presence.details = "Customizing " + GlobalVars.UserConfiguration.ReadSetting("PlayerName"); GlobalVars.presence.state = "In Character Customization"; - GlobalVars.presence.largeImageText = GlobalVars.UserConfiguration.PlayerName + " | Novetus " + GlobalVars.ProgramInformation.Version; + GlobalVars.presence.largeImageText = GlobalVars.UserConfiguration.ReadSetting("PlayerName") + " | Novetus " + GlobalVars.ProgramInformation.Version; GlobalVars.presence.smallImageText = "In Character Customization"; break; case GlobalVars.LauncherState.InEasterEggGame: GlobalVars.presence.smallImageKey = GlobalVars.image_ingame; GlobalVars.presence.details = ValidMapname; GlobalVars.presence.state = "Reading a message."; - GlobalVars.presence.largeImageText = GlobalVars.UserConfiguration.PlayerName + " | Novetus " + GlobalVars.ProgramInformation.Version; + GlobalVars.presence.largeImageText = GlobalVars.UserConfiguration.ReadSetting("PlayerName") + " | Novetus " + GlobalVars.ProgramInformation.Version; GlobalVars.presence.smallImageText = "Reading a message."; break; case GlobalVars.LauncherState.LoadingURI: GlobalVars.presence.smallImageKey = GlobalVars.image_ingame; GlobalVars.presence.details = ValidMapname; GlobalVars.presence.state = "Joining a " + clientname + " Multiplayer Game"; - GlobalVars.presence.largeImageText = GlobalVars.UserConfiguration.PlayerName + " | Novetus " + GlobalVars.ProgramInformation.Version; + GlobalVars.presence.largeImageText = GlobalVars.UserConfiguration.ReadSetting("PlayerName") + " | Novetus " + GlobalVars.ProgramInformation.Version; GlobalVars.presence.smallImageText = "Joining a " + clientname + " Multiplayer Game"; break; default: @@ -435,7 +435,7 @@ namespace Novetus.Core Util.FixedFileDelete(fullFilePath); } - if (GlobalVars.UserConfiguration.QualityLevel != Settings.Level.Custom) + if (GlobalVars.UserConfiguration.ReadSettingInt("QualityLevel") != (int)Settings.Level.Custom) { int GraphicsMode = 0; @@ -450,7 +450,7 @@ namespace Novetus.Core info.ClientLoadOptions != Settings.ClientLoadOptions.Client_2008AndUp_NoGraphicsOptions) { - switch (GlobalVars.UserConfiguration.GraphicsMode) + switch ((Settings.Mode)GlobalVars.UserConfiguration.ReadSettingInt("GraphicsMode")) { case Settings.Mode.OpenGLStable: switch (info.ClientLoadOptions) @@ -497,7 +497,7 @@ namespace Novetus.Core int AA = 1; bool Shadows_2007 = true; - switch (GlobalVars.UserConfiguration.QualityLevel) + switch ((Settings.Level)GlobalVars.UserConfiguration.ReadSettingInt("QualityLevel")) { case Settings.Level.Automatic: //set everything to automatic. Some ultra settings will still be enabled. @@ -576,7 +576,7 @@ namespace Novetus.Core info.ClientLoadOptions != Settings.ClientLoadOptions.Client_2008AndUp_NoGraphicsOptions) { - switch (GlobalVars.UserConfiguration.GraphicsMode) + switch ((Settings.Mode)GlobalVars.UserConfiguration.ReadSettingInt("GraphicsMode")) { case Settings.Mode.OpenGLStable: switch (info.ClientLoadOptions) @@ -651,7 +651,7 @@ namespace Novetus.Core if (info.ClientLoadOptions != Settings.ClientLoadOptions.Client_2007_NoGraphicsOptions || info.ClientLoadOptions != Settings.ClientLoadOptions.Client_2008AndUp_NoGraphicsOptions) { - switch (GlobalVars.UserConfiguration.GraphicsMode) + switch ((Settings.Mode)GlobalVars.UserConfiguration.ReadSettingInt("GraphicsMode")) { case Settings.Mode.OpenGLStable: switch (info.ClientLoadOptions) @@ -813,7 +813,7 @@ namespace Novetus.Core public static string GetLuaFileName(ScriptType type) { - return GetLuaFileName(GlobalVars.UserConfiguration.SelectedClient, type); + return GetLuaFileName(GlobalVars.UserConfiguration.ReadSetting("SelectedClient"), type); } public static string GetLuaFileName(string ClientName, ScriptType type) @@ -877,7 +877,7 @@ namespace Novetus.Core public static string GetClientEXEDir(ScriptType type) { - return GetClientEXEDir(GlobalVars.UserConfiguration.SelectedClient, type); + return GetClientEXEDir(GlobalVars.UserConfiguration.ReadSetting("SelectedClient"), type); } public static string GetClientEXEDir(string ClientName, ScriptType type) @@ -963,12 +963,12 @@ namespace Novetus.Core public static void DecompressMap(ScriptType type, bool nomap) { - if ((type != ScriptType.Client || type != ScriptType.EasterEgg) && !nomap && GlobalVars.UserConfiguration.Map.Contains(".bz2")) + if ((type != ScriptType.Client || type != ScriptType.EasterEgg) && !nomap && GlobalVars.UserConfiguration.ReadSetting("Map").Contains(".bz2")) { - Util.Decompress(GlobalVars.UserConfiguration.MapPath, true); + Util.Decompress(GlobalVars.UserConfiguration.ReadSetting("MapPath"), true); - GlobalVars.UserConfiguration.MapPath = GlobalVars.UserConfiguration.MapPath.Replace(".bz2", ""); - GlobalVars.UserConfiguration.Map = GlobalVars.UserConfiguration.Map.Replace(".bz2", ""); + GlobalVars.UserConfiguration.SaveSetting("MapPath", GlobalVars.UserConfiguration.ReadSetting("MapPath").Replace(".bz2", "")); + GlobalVars.UserConfiguration.SaveSetting("Map", GlobalVars.UserConfiguration.ReadSetting("Map").Replace(".bz2", "")); GlobalVars.isMapCompressed = true; } } @@ -977,9 +977,9 @@ namespace Novetus.Core { if (GlobalVars.isMapCompressed) { - Util.FixedFileDelete(GlobalVars.UserConfiguration.MapPath); - GlobalVars.UserConfiguration.MapPath = GlobalVars.UserConfiguration.MapPath.Replace(".rbxlx", ".rbxlx.bz2").Replace(".rbxl", ".rbxl.bz2"); - GlobalVars.UserConfiguration.Map = GlobalVars.UserConfiguration.Map.Replace(".rbxlx", ".rbxlx.bz2").Replace(".rbxl", ".rbxl.bz2"); + Util.FixedFileDelete(GlobalVars.UserConfiguration.ReadSetting("MapPath")); + GlobalVars.UserConfiguration.SaveSetting("MapPath", GlobalVars.UserConfiguration.ReadSetting("MapPath").Replace(".rbxlx", ".rbxlx.bz2").Replace(".rbxl", ".rbxl.bz2")); + GlobalVars.UserConfiguration.SaveSetting("Map", GlobalVars.UserConfiguration.ReadSetting("Map").Replace(".rbxlx", ".rbxlx.bz2").Replace(".rbxl", ".rbxl.bz2")); GlobalVars.isMapCompressed = false; } } @@ -992,9 +992,9 @@ namespace Novetus.Core #endif { #if URI - LaunchRBXClient(GlobalVars.UserConfiguration.SelectedClient, type, no3d, nomap, e, label); + LaunchRBXClient(GlobalVars.UserConfiguration.ReadSetting("SelectedClient"), type, no3d, nomap, e, label); #else - LaunchRBXClient(GlobalVars.UserConfiguration.SelectedClient, type, no3d, nomap, e); + LaunchRBXClient(GlobalVars.UserConfiguration.ReadSetting("SelectedClient"), type, no3d, nomap, e); #endif } @@ -1010,7 +1010,7 @@ namespace Novetus.Core string[] parsedFileParams = extractedFile.Split('|'); string filePath = parsedFileParams[0]; string fileMD5 = parsedFileParams[1]; - string fullFilePath = GlobalPaths.ClientDir + @"\\" + GlobalVars.UserConfiguration.SelectedClient + @"\\" + filePath; + string fullFilePath = GlobalPaths.ClientDir + @"\\" + GlobalVars.UserConfiguration.ReadSetting("SelectedClient") + @"\\" + filePath; if (!CheckMD5(fileMD5, fullFilePath)) { @@ -1137,7 +1137,7 @@ namespace Novetus.Core FileManagement.ReloadLoadoutValue(true); break; case ScriptType.Server: - if (GlobalVars.UserConfiguration.FirstServerLaunch) + if (GlobalVars.UserConfiguration.ReadSettingBool("FirstServerLaunch")) { #if LAUNCHER string hostingTips = "Tips for your first time:\n\nMake sure your server's port forwarded (set up in your router), going through a tunnel server, or running from UPnP.\n" + @@ -1153,7 +1153,7 @@ namespace Novetus.Core Util.ConsolePrint("Tips: " + hostingTips, 4); } #endif - GlobalVars.UserConfiguration.FirstServerLaunch = false; + GlobalVars.UserConfiguration.SaveSettingBool("FirstServerLaunch", false); } break; case ScriptType.Solo: @@ -1167,8 +1167,8 @@ namespace Novetus.Core string luafile = GetLuaFileName(ClientName, type); string rbxexe = GetClientEXEDir(ClientName, type); bool isEasterEgg = (type.Equals(ScriptType.EasterEggServer)); - string mapfile = isEasterEgg ? GlobalPaths.DataDir + "\\Appreciation.rbxl" : (nomap ? (type.Equals(ScriptType.Studio) ? GlobalPaths.ConfigDir + "\\Place1.rbxl" : "") : GlobalVars.UserConfiguration.MapPath); - string mapname = isEasterEgg ? "" : (nomap ? "" : GlobalVars.UserConfiguration.Map); + string mapfile = isEasterEgg ? GlobalPaths.DataDir + "\\Appreciation.rbxl" : (nomap ? (type.Equals(ScriptType.Studio) ? GlobalPaths.ConfigDir + "\\Place1.rbxl" : "") : GlobalVars.UserConfiguration.ReadSetting("MapPath")); + string mapname = isEasterEgg ? "" : (nomap ? "" : GlobalVars.UserConfiguration.ReadSetting("Map")); FileFormat.ClientInfo info = GetClientInfoValues(ClientName); string quote = "\""; string args = ""; @@ -1364,7 +1364,7 @@ namespace Novetus.Core client.Exited += e; } client.Start(); - client.PriorityClass = GlobalVars.UserConfiguration.Priority; + client.PriorityClass = (ProcessPriorityClass)GlobalVars.UserConfiguration.ReadSettingInt("Priority"); if (!customization) { @@ -1449,7 +1449,7 @@ namespace Novetus.Core public static string GetScriptFuncForType(ScriptType type) { - return GetScriptFuncForType(GlobalVars.UserConfiguration.SelectedClient, type); + return GetScriptFuncForType(GlobalVars.UserConfiguration.ReadSetting("SelectedClient"), type); } public static string GetScriptFuncForType(string ClientName, ScriptType type) @@ -1488,33 +1488,33 @@ namespace Novetus.Core case ScriptType.Client: case ScriptType.EasterEgg: return "_G.CSConnect(" - + (info.UsesID ? GlobalVars.UserConfiguration.UserID : 0) + ",'" + + (info.UsesID ? GlobalVars.UserConfiguration.ReadSettingInt("UserID") : 0) + ",'" + GlobalVars.CurrentServer.ServerIP + "'," + GlobalVars.CurrentServer.ServerPort + ",'" - + (info.UsesPlayerName ? GlobalVars.UserConfiguration.PlayerName : "Player") + "'," + + (info.UsesPlayerName ? GlobalVars.UserConfiguration.ReadSetting("PlayerName") : "Player") + "'," + GlobalVars.Loadout + "," + md5s + ",'" + GlobalVars.PlayerTripcode + ((GlobalVars.ValidatedExtraFiles > 0) ? "'," + GlobalVars.ValidatedExtraFiles.ToString() + "," : "',0,") - + GlobalVars.UserConfiguration.NewGUI.ToString().ToLower() + ");"; + + GlobalVars.UserConfiguration.ReadSetting("NewGUI").ToLower() + ");"; case ScriptType.Server: case ScriptType.EasterEggServer: return "_G.CSServer(" - + GlobalVars.UserConfiguration.RobloxPort + "," - + GlobalVars.UserConfiguration.PlayerLimit + "," + + GlobalVars.UserConfiguration.ReadSetting("RobloxPort") + "," + + GlobalVars.UserConfiguration.ReadSetting("PlayerLimit") + "," + md5s + "," - + GlobalVars.UserConfiguration.ShowServerNotifications.ToString().ToLower() + + GlobalVars.UserConfiguration.ReadSetting("ShowServerNotifications").ToLower() + ((GlobalVars.ValidatedExtraFiles > 0) ? "," + GlobalVars.ValidatedExtraFiles.ToString() + "," : ",0,") - + GlobalVars.UserConfiguration.NewGUI.ToString().ToLower() + ");"; + + GlobalVars.UserConfiguration.ReadSetting("NewGUI").ToLower() + ");"; case ScriptType.Solo: return "_G.CSSolo(" - + (info.UsesID ? GlobalVars.UserConfiguration.UserID : 0) + ",'" - + (info.UsesPlayerName ? GlobalVars.UserConfiguration.PlayerName : "Player") + "'," + + (info.UsesID ? GlobalVars.UserConfiguration.ReadSettingInt("UserID") : 0) + ", '" + + (info.UsesPlayerName ? GlobalVars.UserConfiguration.ReadSetting("PlayerName") : "Player") + "'," + GlobalVars.soloLoadout + "," - + GlobalVars.UserConfiguration.NewGUI.ToString().ToLower() + ");"; + + GlobalVars.UserConfiguration.ReadSetting("NewGUI").ToLower() + ");"; case ScriptType.Studio: return "_G.CSStudio(" - + GlobalVars.UserConfiguration.NewGUI.ToString().ToLower() + ");"; + + GlobalVars.UserConfiguration.ReadSetting("NewGUI").ToLower() + ");"; default: return ""; } @@ -1542,7 +1542,7 @@ namespace Novetus.Core public static void GenerateScriptForClient(ScriptType type) { - GenerateScriptForClient(GlobalVars.UserConfiguration.SelectedClient, type); + GenerateScriptForClient(GlobalVars.UserConfiguration.ReadSetting("SelectedClient"), type); } public static void GenerateScriptForClient(string ClientName, ScriptType type) @@ -1681,7 +1681,7 @@ namespace Novetus.Core public static int ConvertIconStringToInt() { - switch (GlobalVars.UserCustomization.Icon) + switch (GlobalVars.UserCustomization.ReadSetting("Icon")) { case "BC": return 1; @@ -1738,14 +1738,14 @@ namespace Novetus.Core public static string CopyMapToRBXAsset() { - string clientcontentpath = GlobalPaths.ClientDir + @"\\" + GlobalVars.UserConfiguration.SelectedClient + @"\\content\\temp.rbxl"; - Util.FixedFileCopy(GlobalVars.UserConfiguration.MapPath, clientcontentpath, true); + string clientcontentpath = GlobalPaths.ClientDir + @"\\" + GlobalVars.UserConfiguration.ReadSetting("SelectedClient") + @"\\content\\temp.rbxl"; + Util.FixedFileCopy(GlobalVars.UserConfiguration.ReadSetting("MapPath"), clientcontentpath, true); return GlobalPaths.AltBaseGameDir + "temp.rbxl"; } public static string CompileScript(string code, string tag, string endtag, string mapfile, string luafile, string rbxexe, bool usesharedtags = true) { - return CompileScript(GlobalVars.UserConfiguration.SelectedClient, code, tag, endtag, mapfile, luafile, rbxexe, usesharedtags); + return CompileScript(GlobalVars.UserConfiguration.ReadSetting("SelectedClient"), code, tag, endtag, mapfile, luafile, rbxexe, usesharedtags); } public static string CompileScript(string ClientName, string code, string tag, string endtag, string mapfile, string luafile, string rbxexe, bool usesharedtags = true) @@ -1815,44 +1815,44 @@ namespace Novetus.Core #else string md5dir = !info.AlreadyHasSecurity ? SecurityFuncs.GenerateMD5(GlobalPaths.RootPathLauncher + "\\Novetus.exe") : ""; #endif - string md5script = !info.AlreadyHasSecurity ? SecurityFuncs.GenerateMD5(GlobalPaths.ClientDir + @"\\" + GlobalVars.UserConfiguration.SelectedClient + @"\\content\\scripts\\" + GlobalPaths.ScriptName + ".lua") : ""; + string md5script = !info.AlreadyHasSecurity ? SecurityFuncs.GenerateMD5(GlobalPaths.ClientDir + @"\\" + GlobalVars.UserConfiguration.ReadSetting("SelectedClient") + @"\\content\\scripts\\" + GlobalPaths.ScriptName + ".lua") : ""; string md5exe = !info.AlreadyHasSecurity ? SecurityFuncs.GenerateMD5(rbxexe) : ""; string md5sd = "'" + md5exe + "','" + md5dir + "','" + md5script + "'"; string md5s = "'" + info.ClientMD5 + "','" + md5dir + "','" + info.ScriptMD5 + "'"; string compiled = extractedCode.Replace("%version%", GlobalVars.ProgramInformation.Version) .Replace("%mapfile%", mapfile) .Replace("%luafile%", luafile) - .Replace("%charapp%", GlobalVars.UserCustomization.CharacterID) + .Replace("%charapp%", GlobalVars.UserCustomization.ReadSetting("CharacterID")) .Replace("%server%", GlobalVars.CurrentServer.ToString()) .Replace("%ip%", GlobalVars.CurrentServer.ServerIP) - .Replace("%port%", GlobalVars.UserConfiguration.RobloxPort.ToString()) + .Replace("%port%", GlobalVars.UserConfiguration.ReadSetting("RobloxPort")) .Replace("%joinport%", GlobalVars.CurrentServer.ServerPort.ToString()) - .Replace("%name%", GlobalVars.UserConfiguration.PlayerName) + .Replace("%name%", GlobalVars.UserConfiguration.ReadSetting("PlayerName")) .Replace("%icone%", ConvertIconStringToInt().ToString()) - .Replace("%icon%", GlobalVars.UserCustomization.Icon) - .Replace("%id%", GlobalVars.UserConfiguration.UserID.ToString()) - .Replace("%face%", GlobalVars.UserCustomization.Face) - .Replace("%head%", GlobalVars.UserCustomization.Head) - .Replace("%tshirt%", GlobalVars.UserCustomization.TShirt) - .Replace("%shirt%", GlobalVars.UserCustomization.Shirt) - .Replace("%pants%", GlobalVars.UserCustomization.Pants) - .Replace("%hat1%", GlobalVars.UserCustomization.Hat1) - .Replace("%hat2%", GlobalVars.UserCustomization.Hat2) - .Replace("%hat3%", GlobalVars.UserCustomization.Hat3) - .Replace("%faced%", GlobalVars.UserCustomization.Face.Contains("http://") ? GlobalVars.UserCustomization.Face : GlobalPaths.faceGameDir + GlobalVars.UserCustomization.Face) - .Replace("%headd%", GlobalPaths.headGameDir + GlobalVars.UserCustomization.Head) - .Replace("%tshirtd%", GlobalVars.UserCustomization.TShirt.Contains("http://") ? GlobalVars.UserCustomization.TShirt : GlobalPaths.tshirtGameDir + GlobalVars.UserCustomization.TShirt) - .Replace("%shirtd%", GlobalVars.UserCustomization.Shirt.Contains("http://") ? GlobalVars.UserCustomization.Shirt : GlobalPaths.shirtGameDir + GlobalVars.UserCustomization.Shirt) - .Replace("%pantsd%", GlobalVars.UserCustomization.Pants.Contains("http://") ? GlobalVars.UserCustomization.Pants : GlobalPaths.pantsGameDir + GlobalVars.UserCustomization.Pants) - .Replace("%hat1d%", GlobalPaths.hatGameDir + GlobalVars.UserCustomization.Hat1) - .Replace("%hat2d%", GlobalPaths.hatGameDir + GlobalVars.UserCustomization.Hat2) - .Replace("%hat3d%", GlobalPaths.hatGameDir + GlobalVars.UserCustomization.Hat3) - .Replace("%headcolor%", GlobalVars.UserCustomization.HeadColorID.ToString()) - .Replace("%torsocolor%", GlobalVars.UserCustomization.TorsoColorID.ToString()) - .Replace("%larmcolor%", GlobalVars.UserCustomization.LeftArmColorID.ToString()) - .Replace("%llegcolor%", GlobalVars.UserCustomization.LeftLegColorID.ToString()) - .Replace("%rarmcolor%", GlobalVars.UserCustomization.RightArmColorID.ToString()) - .Replace("%rlegcolor%", GlobalVars.UserCustomization.RightLegColorID.ToString()) + .Replace("%icon%", GlobalVars.UserCustomization.ReadSetting("Icon")) + .Replace("%id%", GlobalVars.UserConfiguration.ReadSetting("UserID")) + .Replace("%face%", GlobalVars.UserCustomization.ReadSetting("Face")) + .Replace("%head%", GlobalVars.UserCustomization.ReadSetting("Head")) + .Replace("%tshirt%", GlobalVars.UserCustomization.ReadSetting("TShirt")) + .Replace("%shirt%", GlobalVars.UserCustomization.ReadSetting("Shirt")) + .Replace("%pants%", GlobalVars.UserCustomization.ReadSetting("Pants")) + .Replace("%hat1%", GlobalVars.UserCustomization.ReadSetting("Hat1")) + .Replace("%hat2%", GlobalVars.UserCustomization.ReadSetting("Hat2")) + .Replace("%hat3%", GlobalVars.UserCustomization.ReadSetting("Hat3")) + .Replace("%faced%", GlobalVars.UserCustomization.ReadSetting("Face").Contains("http://") ? GlobalVars.UserCustomization.ReadSetting("Face") : GlobalPaths.faceGameDir + GlobalVars.UserCustomization.ReadSetting("Face")) + .Replace("%headd%", GlobalPaths.headGameDir + GlobalVars.UserCustomization.ReadSetting("Head")) + .Replace("%tshirtd%", GlobalVars.UserCustomization.ReadSetting("TShirt").Contains("http://") ? GlobalVars.UserCustomization.ReadSetting("TShirt") : GlobalPaths.tshirtGameDir + GlobalVars.UserCustomization.ReadSetting("TShirt")) + .Replace("%shirtd%", GlobalVars.UserCustomization.ReadSetting("Shirt").Contains("http://") ? GlobalVars.UserCustomization.ReadSetting("Shirt") : GlobalPaths.shirtGameDir + GlobalVars.UserCustomization.ReadSetting("Shirt")) + .Replace("%pantsd%", GlobalVars.UserCustomization.ReadSetting("Pants").Contains("http://") ? GlobalVars.UserCustomization.ReadSetting("Pants") : GlobalPaths.pantsGameDir + GlobalVars.UserCustomization.ReadSetting("Pants")) + .Replace("%hat1d%", GlobalPaths.hatGameDir + GlobalVars.UserCustomization.ReadSetting("Hat1")) + .Replace("%hat2d%", GlobalPaths.hatGameDir + GlobalVars.UserCustomization.ReadSetting("Hat1")) + .Replace("%hat3d%", GlobalPaths.hatGameDir + GlobalVars.UserCustomization.ReadSetting("Hat1")) + .Replace("%headcolor%", GlobalVars.UserCustomization.ReadSetting("HeadColorID")) + .Replace("%torsocolor%", GlobalVars.UserCustomization.ReadSetting("TorsoColorID")) + .Replace("%larmcolor%", GlobalVars.UserCustomization.ReadSetting("LeftArmColorID")) + .Replace("%llegcolor%", GlobalVars.UserCustomization.ReadSetting("LeftLegColorID")) + .Replace("%rarmcolor%", GlobalVars.UserCustomization.ReadSetting("RightArmColorID")) + .Replace("%rlegcolor%", GlobalVars.UserCustomization.ReadSetting("RightLegColorID")) .Replace("%md5launcher%", md5dir) .Replace("%md5script%", info.ScriptMD5) .Replace("%md5exe%", info.ClientMD5) @@ -1860,16 +1860,16 @@ namespace Novetus.Core .Replace("%md5exed%", md5exe) .Replace("%md5s%", md5s) .Replace("%md5sd%", md5sd) - .Replace("%limit%", GlobalVars.UserConfiguration.PlayerLimit.ToString()) - .Replace("%extra%", GlobalVars.UserCustomization.Extra) - .Replace("%hat4%", GlobalVars.UserCustomization.Extra) - .Replace("%extrad%", GlobalPaths.extraGameDir + GlobalVars.UserCustomization.Extra) - .Replace("%hat4d%", GlobalPaths.hatGameDir + GlobalVars.UserCustomization.Extra) - .Replace("%mapfiled%", GlobalPaths.BaseGameDir + GlobalVars.UserConfiguration.MapPathSnip.Replace(@"\\", @"\").Replace(@"/", @"\")) + .Replace("%limit%", GlobalVars.UserConfiguration.ReadSetting("PlayerLimit")) + .Replace("%extra%", GlobalVars.UserCustomization.ReadSetting("Extra")) + .Replace("%hat4%", GlobalVars.UserCustomization.ReadSetting("Extra")) + .Replace("%extrad%", GlobalPaths.extraGameDir + GlobalVars.UserCustomization.ReadSetting("Extra")) + .Replace("%hat4d%", GlobalPaths.hatGameDir + GlobalVars.UserCustomization.ReadSetting("Extra")) + .Replace("%mapfiled%", GlobalPaths.BaseGameDir + GlobalVars.UserConfiguration.ReadSetting("MapPathSnip").Replace(@"\\", @"\").Replace(@"/", @"\")) .Replace("%mapfilec%", extractedCode.Contains("%mapfilec%") ? CopyMapToRBXAsset() : "") .Replace("%tripcode%", GlobalVars.PlayerTripcode) .Replace("%scripttype%", Generator.GetNameForType(type)) - .Replace("%notifications%", GlobalVars.UserConfiguration.ShowServerNotifications.ToString().ToLower()) + .Replace("%notifications%", GlobalVars.UserConfiguration.ReadSetting("ShowServerNotifications").ToLower()) .Replace("%loadout%", code.Contains("") ? GlobalVars.soloLoadout : GlobalVars.Loadout) .Replace("%validatedextrafiles%", GlobalVars.ValidatedExtraFiles.ToString()) .Replace("%argstring%", GetRawArgsForType(type, ClientName, luafile)) @@ -1881,7 +1881,7 @@ namespace Novetus.Core .Replace("%shirttexidlocal%", GlobalVars.ShirtTextureLocal) .Replace("%pantstexidlocal%", GlobalVars.PantsTextureLocal) .Replace("%facetexlocal%", GlobalVars.FaceTextureLocal) - .Replace("%newgui%", GlobalVars.UserConfiguration.NewGUI.ToString().ToLower()); + .Replace("%newgui%", GlobalVars.UserConfiguration.ReadSetting("NewGUI").ToLower()); return compiled; } diff --git a/Novetus/NovetusCore/StorageAndFunctions/FileManagement.cs b/Novetus/NovetusCore/StorageAndFunctions/FileManagement.cs index bbf7475..e6be8c4 100644 --- a/Novetus/NovetusCore/StorageAndFunctions/FileManagement.cs +++ b/Novetus/NovetusCore/StorageAndFunctions/FileManagement.cs @@ -58,127 +58,209 @@ namespace Novetus.Core } #endregion - #region Configuration - public class Config + #region ConfigBase + public class ConfigBase { - public Config() + public INIFile INI; + private string Section { get; set; } + private string Path { get; set; } + + public ConfigBase(string section, string path) { - SelectedClient = ""; - Map = ""; - CloseOnLaunch = false; - UserID = 0; - PlayerName = "Player"; - RobloxPort = 53640; - PlayerLimit = 12; - UPnP = false; - DisabledAssetSDKHelp = false; - DiscordPresence = true; - MapPath = ""; - MapPathSnip = ""; - GraphicsMode = Settings.Mode.Automatic; - QualityLevel = Settings.Level.Automatic; - LauncherStyle = Settings.Style.Stylish; - AssetSDKFixerSaveBackups = true; - AlternateServerIP = ""; - ShowServerNotifications = false; - ServerBrowserServerName = "Novetus"; - ServerBrowserServerAddress = ""; - Priority = ProcessPriorityClass.RealTime; - FirstServerLaunch = true; - NewGUI = false; - URIQuickConfigure = true; - BootstrapperShowUI = true; - WebProxyInitialSetupRequired = true; - WebProxyEnabled = false; + Section = section; + Path = path; + + bool fileExists = File.Exists(Path); + + if (!fileExists) + { + CreateFile(); + } + else + { + INI = new INIFile(Path, false); + } } - public string SelectedClient { get; set; } - public string Map { get; set; } - public bool CloseOnLaunch { get; set; } - public int UserID { get; set; } - public string PlayerName { get; set; } - public int RobloxPort { get; set; } - public int PlayerLimit { get; set; } - public bool UPnP { get; set; } - public bool DisabledAssetSDKHelp { get; set; } - public bool DiscordPresence { get; set; } - public string MapPath { get; set; } - public string MapPathSnip { get; set; } - public Settings.Mode GraphicsMode { get; set; } - public Settings.Level QualityLevel { get; set; } - public Settings.Style LauncherStyle { get; set; } - public bool AssetSDKFixerSaveBackups { get; set; } - public string AlternateServerIP { get; set; } - public bool ShowServerNotifications { get; set; } - public string ServerBrowserServerName { get; set; } - public string ServerBrowserServerAddress { get; set; } - public ProcessPriorityClass Priority { get; set; } - public bool FirstServerLaunch { get; set; } - public bool NewGUI { get; set; } - public bool URIQuickConfigure { get; set; } - public bool BootstrapperShowUI { get; set; } - public bool WebProxyInitialSetupRequired { get; set; } - public bool WebProxyEnabled { get; set; } + public void CreateFile() + { + INI = new INIFile(Path); + GenerateDefaults(); + GenerateDefaultsEvent(); + } + + public virtual void GenerateDefaults() + { + //defaults go in here. + } + + public virtual void GenerateDefaultsEvent() + { + //generate default event goes in here. + } + + public void LoadAllSettings(string inputPath) + { + File.SetAttributes(Path, FileAttributes.Normal); + File.Replace(inputPath, Path, null); + } + + public void SaveSetting(string name, string value) + { + SaveSetting(Section, name, value); + } + + public void SaveSetting(string section, string name, string value) + { + INI.IniWriteValue(section, name, value); + SaveSettingEvent(); + } + + public void SaveSettingInt(string name, int value) + { + SaveSettingInt(Section, name, value); + } + + public void SaveSettingInt(string section, string name, int value) + { + INI.IniWriteValue(section, name, value.ToString()); + SaveSettingEvent(); + } + + public void SaveSettingBool(string name, bool value) + { + SaveSettingBool(Section, name, value); + } + + public void SaveSettingBool(string section, string name, bool value) + { + INI.IniWriteValue(section, name, value.ToString()); + SaveSettingEvent(); + } + + public virtual void SaveSettingEvent() + { + //save setting event goes in here. + } + + public string ReadSetting(string name) + { + string value = INI.IniReadValue(Section, name); + + if (!string.IsNullOrWhiteSpace(value)) + { + ReadSettingEvent(); + return INI.IniReadValue(Section, name); + } + else + { + return ""; + } + } + + public int ReadSettingInt(string name) + { + return Convert.ToInt32(ReadSetting(name)); + } + + public bool ReadSettingBool(string name) + { + return Convert.ToBoolean(ReadSetting(name)); + } + + public virtual void ReadSettingEvent() + { + //read setting event. + } + } + + #endregion + + #region Configuration + public class Config : ConfigBase + { + public Config() : base("Config", GlobalPaths.ConfigDir + "\\" + GlobalPaths.ConfigName) { } + + public override void GenerateDefaults() + { + SaveSetting("SelectedClient", ""); + SaveSetting("Map", ""); + SaveSettingBool("CloseOnLaunch", false); + SaveSettingInt("UserID", NovetusFuncs.GeneratePlayerID()); + SaveSetting("PlayerName", "Player"); + SaveSettingInt("RobloxPort", 53640); + SaveSettingInt("PlayerLimit", 12); + SaveSettingBool("UPnP", false); + SaveSettingBool("DisabledAssetSDKHelp", false); + SaveSettingBool("DiscordRichPresence", true); + SaveSetting("MapPath", ""); + SaveSetting("MapPathSnip", ""); + SaveSettingInt("GraphicsMode", (int)Settings.Mode.Automatic); + SaveSettingInt("QualityLevel", (int)Settings.Level.Automatic); + + if (Util.IsWineRunning()) + { + SaveSettingInt("LauncherStyle", (int)Settings.Style.Extended); + } + else + { + SaveSettingInt("LauncherStyle", (int)Settings.Style.Stylish); + } + + SaveSettingBool("AssetSDKFixerSaveBackups", true); + SaveSetting("AlternateServerIP", ""); + SaveSettingBool("ShowServerNotifications", false); + SaveSetting("ServerBrowserServerName", "Novetus"); + SaveSetting("ServerBrowserServerAddress", ""); + SaveSettingInt("Priority", (int)ProcessPriorityClass.RealTime); + SaveSettingBool("FirstServerLaunch", true); + SaveSettingBool("NewGUI", false); + SaveSettingBool("URIQuickConfigure", true); + SaveSettingBool("BootstrapperShowUI", true); + SaveSettingBool("WebProxyInitialSetupRequired", true); + SaveSettingBool("WebProxyEnabled", false); + } } #endregion #region Customization Configuration - public class CustomizationConfig + public class CustomizationConfig : ConfigBase { - public CustomizationConfig() + public CustomizationConfig() : base("Items", GlobalPaths.ConfigDir + "\\" + GlobalPaths.ConfigNameCustomization) { } + + public override void GenerateDefaults() { - Hat1 = "NoHat.rbxm"; - Hat2 = "NoHat.rbxm"; - Hat3 = "NoHat.rbxm"; - Face = "DefaultFace.rbxm"; - Head = "DefaultHead.rbxm"; - TShirt = "NoTShirt.rbxm"; - Shirt = "NoShirt.rbxm"; - Pants = "NoPants.rbxm"; - Icon = "NBC"; - Extra = "NoExtra.rbxm"; - HeadColorID = 24; - TorsoColorID = 23; - LeftArmColorID = 24; - RightArmColorID = 24; - LeftLegColorID = 119; - RightLegColorID = 119; - HeadColorString = "Color [A=255, R=245, G=205, B=47]"; - TorsoColorString = "Color [A=255, R=13, G=105, B=172]"; - LeftArmColorString = "Color [A=255, R=245, G=205, B=47]"; - RightArmColorString = "Color [A=255, R=245, G=205, B=47]"; - LeftLegColorString = "Color [A=255, R=164, G=189, B=71]"; - RightLegColorString = "Color [A=255, R=164, G=189, B=71]"; - ExtraSelectionIsHat = false; - ShowHatsInExtra = false; - CharacterID = ""; + SaveSetting("Items", "Hat1", "NoHat.rbxm"); + SaveSetting("Items", "Hat2", "NoHat.rbxm"); + SaveSetting("Items", "Hat3", "NoHat.rbxm"); + SaveSetting("Items", "Face", "DefaultFace.rbxm"); + SaveSetting("Items", "Head", "DefaultHead.rbxm"); + SaveSetting("Items", "TShirt", "NoTShirt.rbxm"); + SaveSetting("Items", "Shirt", "NoShirt.rbxm"); + SaveSetting("Items", "Pants", "NoPants.rbxm"); + SaveSetting("Items", "Icon", "NBC"); + SaveSetting("Items", "Extra", "NoExtra.rbxm"); + SaveSettingInt("Colors", "HeadColorID", 24); + SaveSettingInt("Colors", "TorsoColorID", 23); + SaveSettingInt("Colors", "LeftArmColorID", 24); + SaveSettingInt("Colors", "RightArmColorID", 24); + SaveSettingInt("Colors", "LeftLegColorID", 119); + SaveSettingInt("Colors", "RightLegColorID", 119); + SaveSetting("Colors", "HeadColorString", "Color [A=255, R=245, G=205, B=47]"); + SaveSetting("Colors", "TorsoColorString", "Color [A=255, R=13, G=105, B=172]"); + SaveSetting("Colors", "LeftArmColorString", "Color [A=255, R=245, G=205, B=47]"); + SaveSetting("Colors", "RightArmColorString", "Color [A=255, R=245, G=205, B=47]"); + SaveSetting("Colors", "LeftLegColorString", "Color [A=255, R=164, G=189, B=71]"); + SaveSetting("Colors", "RightLegColorString", "Color [A=255, R=164, G=189, B=71]"); + SaveSettingBool("Other", "ExtraSelectionIsHat", false); + SaveSettingBool("Other", "ShowHatsInExtra", false); + SaveSetting("Other", "CharacterID", ""); } - public string Hat1 { get; set; } - public string Hat2 { get; set; } - public string Hat3 { get; set; } - public string Face { get; set; } - public string Head { get; set; } - public string TShirt { get; set; } - public string Shirt { get; set; } - public string Pants { get; set; } - public string Icon { get; set; } - public string Extra { get; set; } - public int HeadColorID { get; set; } - public int TorsoColorID { get; set; } - public int LeftArmColorID { get; set; } - public int RightArmColorID { get; set; } - public int LeftLegColorID { get; set; } - public int RightLegColorID { get; set; } - public string HeadColorString { get; set; } - public string TorsoColorString { get; set; } - public string LeftArmColorString { get; set; } - public string RightArmColorString { get; set; } - public string LeftLegColorString { get; set; } - public string RightLegColorString { get; set; } - public bool ExtraSelectionIsHat { get; set; } - public bool ShowHatsInExtra { get; set; } - public string CharacterID { get; set; } + public override void ReadSettingEvent() + { + FileManagement.ReloadLoadoutValue(); + } } #endregion @@ -568,7 +650,7 @@ namespace Novetus.Core public void LoadImage() { string ItemNameFixed = ItemName.Replace(" ", ""); - string dir = CopyToItemDir ? ItemDir + "\\" + ItemNameFixed : GlobalPaths.extradir + "\\icons\\" + GlobalVars.UserConfiguration.PlayerName; + string dir = CopyToItemDir ? ItemDir + "\\" + ItemNameFixed : GlobalPaths.extradir + "\\icons\\" + GlobalVars.UserConfiguration.ReadSetting("PlayerName"); if (openFileDialog1.ShowDialog() == DialogResult.OK) { @@ -629,7 +711,7 @@ namespace Novetus.Core string verNumber = "Invalid File"; - INIFile ini = new INIFile(infopath); + INIFile ini = new INIFile(infopath, false); string section = "ProgramInfo"; @@ -699,10 +781,10 @@ namespace Novetus.Core GlobalVars.ProgramInformation.InitialBootup = Convert.ToBoolean(initialBootup); GlobalVars.ProgramInformation.VersionName = verNumber; GlobalVars.ProgramInformation.IsSnapshot = Convert.ToBoolean(isSnapshot); - GlobalVars.UserConfiguration.SelectedClient = GlobalVars.ProgramInformation.DefaultClient; - GlobalVars.UserConfiguration.Map = GlobalVars.ProgramInformation.DefaultMap; - GlobalVars.UserConfiguration.MapPath = GlobalPaths.MapsDir + @"\\" + GlobalVars.ProgramInformation.DefaultMap; - GlobalVars.UserConfiguration.MapPathSnip = GlobalPaths.MapsDirBase + @"\\" + GlobalVars.ProgramInformation.DefaultMap; + 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); } catch (Exception ex) { @@ -714,7 +796,7 @@ namespace Novetus.Core public static void TurnOffInitialSequence() { //READ - INIFile ini = new INIFile(GlobalPaths.ConfigDir + "\\" + GlobalPaths.InfoName); + INIFile ini = new INIFile(GlobalPaths.ConfigDir + "\\" + GlobalPaths.InfoName, false); string section = "ProgramInfo"; string initialBootup = ini.IniReadValue(section, "InitialBootup", "True"); @@ -724,409 +806,29 @@ namespace Novetus.Core } } - public static string ConfigUseOldValIfExists(INIFile ini, string section, string oldKey, string newKey, string val, bool write) + public static void GenerateTripcode() { - if (write) + //Powered by https://github.com/davcs86/csharp-uhwid + string curval = UHWIDEngine.AdvancedUid; + if (!GlobalVars.PlayerTripcode.Equals(curval)) { - if (!ini.IniValueExists(newKey)) - { - if (GlobalVars.ProgramInformation.InitialBootup) - { - if (ini.IniValueExists(oldKey)) - { - ini.IniWriteValue(section, oldKey, val); - } - else - { - ini.IniWriteValue(section, newKey, val); - } - } - else - { - ini.IniWriteValue(section, oldKey, val); - } - } - else - { - ini.IniWriteValue(section, newKey, val); - } - - return ""; - } - else - { - if (ini.IniValueExists(newKey)) - { - return ini.IniReadValue(section, newKey, val); - } - else - { - return ini.IniReadValue(section, oldKey, val); - } - } - } - - private static int ValueInt(string val, int defaultVal) - { - int res; - if (int.TryParse(val, out res)) - { - return Convert.ToInt32(val); - } - else - { - return defaultVal; - } - } - - private static bool ValueBool(string val, bool defaultVal) - { - bool res; - if (bool.TryParse(val, out res)) - { - return Convert.ToBoolean(val); - } - else - { - return defaultVal; - } - } - - public static void Config(string cfgpath, bool write, bool doubleCheck = false) - { - bool forcewrite = false; - - if (!File.Exists(cfgpath)) - { - // force write mode on if the file doesn't exist. - write = true; - forcewrite = true; - } - - if (write) - { - if (Util.IsWineRunning()) - { - GlobalVars.UserConfiguration.LauncherStyle = Settings.Style.Extended; - } - - //WRITE - INIFile ini = new INIFile(cfgpath); - - string section = "Config"; - - ini.IniWriteValue(section, "CloseOnLaunch", GlobalVars.UserConfiguration.CloseOnLaunch.ToString()); - ini.IniWriteValue(section, "UserID", GlobalVars.UserConfiguration.UserID.ToString()); - ini.IniWriteValue(section, "PlayerName", GlobalVars.UserConfiguration.PlayerName.ToString()); - ini.IniWriteValue(section, "SelectedClient", GlobalVars.UserConfiguration.SelectedClient.ToString()); - ini.IniWriteValue(section, "Map", GlobalVars.UserConfiguration.Map.ToString()); - ini.IniWriteValue(section, "RobloxPort", GlobalVars.UserConfiguration.RobloxPort.ToString()); - ini.IniWriteValue(section, "PlayerLimit", GlobalVars.UserConfiguration.PlayerLimit.ToString()); - ini.IniWriteValue(section, "UPnP", GlobalVars.UserConfiguration.UPnP.ToString()); - ini.IniWriteValue(section, "DiscordRichPresence", GlobalVars.UserConfiguration.DiscordPresence.ToString()); - ini.IniWriteValue(section, "MapPath", GlobalVars.UserConfiguration.MapPath.ToString()); - ini.IniWriteValue(section, "MapPathSnip", GlobalVars.UserConfiguration.MapPathSnip.ToString()); - ini.IniWriteValue(section, "GraphicsMode", ((int)GlobalVars.UserConfiguration.GraphicsMode).ToString()); - ini.IniWriteValue(section, "QualityLevel", ((int)GlobalVars.UserConfiguration.QualityLevel).ToString()); - ini.IniWriteValue(section, "Style", ((int)GlobalVars.UserConfiguration.LauncherStyle).ToString()); - ini.IniWriteValue(section, "AlternateServerIP", GlobalVars.UserConfiguration.AlternateServerIP.ToString()); - ini.IniWriteValue(section, "ShowServerNotifications", GlobalVars.UserConfiguration.ShowServerNotifications.ToString()); - ini.IniWriteValue(section, "ServerBrowserServerName", GlobalVars.UserConfiguration.ServerBrowserServerName.ToString()); - ini.IniWriteValue(section, "ServerBrowserServerAddress", GlobalVars.UserConfiguration.ServerBrowserServerAddress.ToString()); - ini.IniWriteValue(section, "ClientLaunchPriority", ((int)GlobalVars.UserConfiguration.Priority).ToString()); - ini.IniWriteValue(section, "FirstServerLaunch", GlobalVars.UserConfiguration.FirstServerLaunch.ToString()); - ini.IniWriteValue(section, "NewGUI", GlobalVars.UserConfiguration.NewGUI.ToString()); - ini.IniWriteValue(section, "URIQuickConfigure", GlobalVars.UserConfiguration.URIQuickConfigure.ToString()); - ini.IniWriteValue(section, "BootstrapperShowUI", GlobalVars.UserConfiguration.BootstrapperShowUI.ToString()); - ini.IniWriteValue(section, "WebProxyInitialSetupRequired", GlobalVars.UserConfiguration.WebProxyInitialSetupRequired.ToString()); - ini.IniWriteValue(section, "WebProxyEnabled", GlobalVars.UserConfiguration.WebProxyEnabled.ToString()); - ConfigUseOldValIfExists(ini, section, "ItemMakerDisableHelpMessage", "AssetSDKDisableHelpMessage", GlobalVars.UserConfiguration.DisabledAssetSDKHelp.ToString(), write); - ConfigUseOldValIfExists(ini, section, "AssetLocalizerSaveBackups", "AssetSDKFixerSaveBackups", GlobalVars.UserConfiguration.AssetSDKFixerSaveBackups.ToString(), write); - - if (forcewrite) - { - // try again.... - Config(cfgpath, false, doubleCheck); - } - } - else - { - try - { - //READ - string closeonlaunch, userid, name, selectedclient, - map, port, limit, upnp, - disablehelpmessage, discord, mappath, mapsnip, - graphics, qualitylevel, style, savebackups, altIP, - showNotifs, SB_Name, SB_Address, priority, - firstServerLaunch, newgui, quickconfigure, bootstrapper, - webproxysetup, webproxy; - - INIFile ini = new INIFile(cfgpath); - - string section = "Config"; - - closeonlaunch = ini.IniReadValue(section, "CloseOnLaunch", GlobalVars.UserConfiguration.CloseOnLaunch.ToString()); - userid = ini.IniReadValue(section, "UserID", GlobalVars.UserConfiguration.UserID.ToString()); - name = ini.IniReadValue(section, "PlayerName", GlobalVars.UserConfiguration.PlayerName.ToString()); - selectedclient = ini.IniReadValue(section, "SelectedClient", GlobalVars.UserConfiguration.SelectedClient.ToString()); - map = ini.IniReadValue(section, "Map", GlobalVars.UserConfiguration.Map.ToString()); - port = ini.IniReadValue(section, "RobloxPort", GlobalVars.UserConfiguration.RobloxPort.ToString()); - limit = ini.IniReadValue(section, "PlayerLimit", GlobalVars.UserConfiguration.PlayerLimit.ToString()); - upnp = ini.IniReadValue(section, "UPnP", GlobalVars.UserConfiguration.UPnP.ToString()); - discord = ini.IniReadValue(section, "DiscordRichPresence", GlobalVars.UserConfiguration.DiscordPresence.ToString()); - mappath = ini.IniReadValue(section, "MapPath", GlobalVars.UserConfiguration.MapPath.ToString()); - mapsnip = ini.IniReadValue(section, "MapPathSnip", GlobalVars.UserConfiguration.MapPathSnip.ToString()); - graphics = ini.IniReadValue(section, "GraphicsMode", ((int)GlobalVars.UserConfiguration.GraphicsMode).ToString()); - qualitylevel = ini.IniReadValue(section, "QualityLevel", ((int)GlobalVars.UserConfiguration.QualityLevel).ToString()); - style = ini.IniReadValue(section, "Style", ((int)GlobalVars.UserConfiguration.LauncherStyle).ToString()); - altIP = ini.IniReadValue(section, "AlternateServerIP", GlobalVars.UserConfiguration.AlternateServerIP.ToString()); - showNotifs = ini.IniReadValue(section, "ShowServerNotifications", GlobalVars.UserConfiguration.ShowServerNotifications.ToString()); - SB_Name = ini.IniReadValue(section, "ServerBrowserServerName", GlobalVars.UserConfiguration.ServerBrowserServerName.ToString()); - SB_Address = ini.IniReadValue(section, "ServerBrowserServerAddress", GlobalVars.UserConfiguration.ServerBrowserServerAddress.ToString()); - priority = ini.IniReadValue(section, "ClientLaunchPriority", ((int)GlobalVars.UserConfiguration.Priority).ToString()); - firstServerLaunch = ini.IniReadValue(section, "FirstServerLaunch", GlobalVars.UserConfiguration.FirstServerLaunch.ToString()); - newgui = ini.IniReadValue(section, "NewGUI", GlobalVars.UserConfiguration.NewGUI.ToString()); - quickconfigure = ini.IniReadValue(section, "URIQuickConfigure", GlobalVars.UserConfiguration.URIQuickConfigure.ToString()); - bootstrapper = ini.IniReadValue(section, "BootstrapperShowUI", GlobalVars.UserConfiguration.BootstrapperShowUI.ToString()); - webproxysetup = ini.IniReadValue(section, "WebProxyInitialSetupRequired", GlobalVars.UserConfiguration.WebProxyInitialSetupRequired.ToString()); - webproxy = ini.IniReadValue(section, "WebProxyEnabled", GlobalVars.UserConfiguration.WebProxyEnabled.ToString()); - disablehelpmessage = ConfigUseOldValIfExists(ini, section, "ItemMakerDisableHelpMessage", "AssetSDKDisableHelpMessage", GlobalVars.UserConfiguration.DisabledAssetSDKHelp.ToString(), write); - savebackups = ConfigUseOldValIfExists(ini, section, "AssetLocalizerSaveBackups", "AssetSDKFixerSaveBackups", GlobalVars.UserConfiguration.AssetSDKFixerSaveBackups.ToString(), write); - - FileFormat.Config DefaultConfiguration = new FileFormat.Config(); - DefaultConfiguration.SelectedClient = GlobalVars.ProgramInformation.DefaultClient; - DefaultConfiguration.Map = GlobalVars.ProgramInformation.DefaultMap; - DefaultConfiguration.MapPath = GlobalPaths.MapsDir + @"\\" + GlobalVars.ProgramInformation.DefaultMap; - DefaultConfiguration.MapPathSnip = GlobalPaths.MapsDirBase + @"\\" + GlobalVars.ProgramInformation.DefaultMap; - - GlobalVars.UserConfiguration.CloseOnLaunch = ValueBool(closeonlaunch, DefaultConfiguration.CloseOnLaunch); - - if (userid.Equals("0")) - { - NovetusFuncs.GeneratePlayerID(); - Config(cfgpath, true); - } - else - { - GlobalVars.UserConfiguration.UserID = ValueInt(userid, DefaultConfiguration.UserID); - } - - GlobalVars.UserConfiguration.PlayerName = name; - GlobalVars.UserConfiguration.SelectedClient = selectedclient; - GlobalVars.UserConfiguration.Map = map; - GlobalVars.UserConfiguration.RobloxPort = ValueInt(port, DefaultConfiguration.RobloxPort); - GlobalVars.UserConfiguration.PlayerLimit = ValueInt(limit, DefaultConfiguration.PlayerLimit); - GlobalVars.UserConfiguration.UPnP = ValueBool(upnp, DefaultConfiguration.UPnP); - GlobalVars.UserConfiguration.DisabledAssetSDKHelp = ValueBool(disablehelpmessage, DefaultConfiguration.DisabledAssetSDKHelp); - GlobalVars.UserConfiguration.DiscordPresence = ValueBool(discord, DefaultConfiguration.DiscordPresence); - GlobalVars.UserConfiguration.MapPathSnip = mapsnip; - GlobalVars.UserConfiguration.GraphicsMode = (Settings.Mode)ValueInt(graphics, Convert.ToInt32(DefaultConfiguration.GraphicsMode)); - GlobalVars.UserConfiguration.QualityLevel = (Settings.Level)ValueInt(qualitylevel, Convert.ToInt32(DefaultConfiguration.QualityLevel)); - GlobalVars.UserConfiguration.LauncherStyle = (Settings.Style)ValueInt(style, Convert.ToInt32(DefaultConfiguration.LauncherStyle)); - GlobalVars.UserConfiguration.AssetSDKFixerSaveBackups = ValueBool(savebackups, DefaultConfiguration.AssetSDKFixerSaveBackups); - GlobalVars.UserConfiguration.AlternateServerIP = altIP; - GlobalVars.UserConfiguration.ShowServerNotifications = ValueBool(showNotifs, DefaultConfiguration.ShowServerNotifications); - GlobalVars.UserConfiguration.ServerBrowserServerName = SB_Name; - GlobalVars.UserConfiguration.ServerBrowserServerAddress = SB_Address; - GlobalVars.UserConfiguration.Priority = (ProcessPriorityClass)ValueInt(priority, Convert.ToInt32(DefaultConfiguration.Priority)); - GlobalVars.UserConfiguration.FirstServerLaunch = ValueBool(firstServerLaunch, DefaultConfiguration.FirstServerLaunch); - GlobalVars.UserConfiguration.NewGUI = ValueBool(newgui, DefaultConfiguration.NewGUI); - GlobalVars.UserConfiguration.URIQuickConfigure = ValueBool(quickconfigure, DefaultConfiguration.URIQuickConfigure); - GlobalVars.UserConfiguration.BootstrapperShowUI = ValueBool(bootstrapper, DefaultConfiguration.BootstrapperShowUI); - GlobalVars.UserConfiguration.WebProxyInitialSetupRequired = ValueBool(webproxysetup, DefaultConfiguration.WebProxyInitialSetupRequired); - GlobalVars.UserConfiguration.WebProxyEnabled = ValueBool(webproxy, DefaultConfiguration.WebProxyEnabled); - - string oldMapath = Path.GetDirectoryName(GlobalVars.UserConfiguration.MapPath); - //update the map path if the file doesn't exist and write to config. - if (oldMapath.Equals(GlobalPaths.MapsDir.Replace(@"\\", @"\")) && File.Exists(mappath)) - { - GlobalVars.UserConfiguration.MapPath = mappath; - } - else - { - GlobalVars.UserConfiguration.MapPath = GlobalPaths.BasePath + @"\\" + GlobalVars.UserConfiguration.MapPathSnip; - Config(cfgpath, true); - } - - if (ResetMapIfNecessary()) - { - Config(cfgpath, true); - } - } - catch (Exception ex) - { - Util.LogExceptions(ex); - Config(cfgpath, true); - } - } - - if (!forcewrite) - { - //Powered by https://github.com/davcs86/csharp-uhwid - string curval = UHWIDEngine.AdvancedUid; - if (!GlobalVars.PlayerTripcode.Equals(curval)) - { - GlobalVars.PlayerTripcode = curval; - } - -#if !BASICLAUNCHER - if (!File.Exists(GlobalPaths.ConfigDir + "\\" + GlobalPaths.ConfigNameCustomization)) - { - Customization(GlobalPaths.ConfigDir + "\\" + GlobalPaths.ConfigNameCustomization, true); - } - else - { - Customization(GlobalPaths.ConfigDir + "\\" + GlobalPaths.ConfigNameCustomization, write); - } -#endif + GlobalVars.PlayerTripcode = curval; } } public static bool ResetMapIfNecessary() { - if (!File.Exists(GlobalVars.UserConfiguration.MapPath)) + if (!File.Exists(GlobalVars.UserConfiguration.ReadSetting("MapPath"))) { - GlobalVars.UserConfiguration.Map = GlobalVars.ProgramInformation.DefaultMap; - GlobalVars.UserConfiguration.MapPath = GlobalPaths.MapsDir + @"\\" + GlobalVars.ProgramInformation.DefaultMap; - GlobalVars.UserConfiguration.MapPathSnip = GlobalPaths.MapsDirBase + @"\\" + GlobalVars.ProgramInformation.DefaultMap; + 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); return true; } return false; } - public static void Customization(string cfgpath, bool write) - { - if (write) - { - //WRITE - INIFile ini = new INIFile(cfgpath); - - string section = "Items"; - - ini.IniWriteValue(section, "Hat1", GlobalVars.UserCustomization.Hat1.ToString()); - ini.IniWriteValue(section, "Hat2", GlobalVars.UserCustomization.Hat2.ToString()); - ini.IniWriteValue(section, "Hat3", GlobalVars.UserCustomization.Hat3.ToString()); - ini.IniWriteValue(section, "Face", GlobalVars.UserCustomization.Face.ToString()); - ini.IniWriteValue(section, "Head", GlobalVars.UserCustomization.Head.ToString()); - ini.IniWriteValue(section, "TShirt", GlobalVars.UserCustomization.TShirt.ToString()); - ini.IniWriteValue(section, "Shirt", GlobalVars.UserCustomization.Shirt.ToString()); - ini.IniWriteValue(section, "Pants", GlobalVars.UserCustomization.Pants.ToString()); - ini.IniWriteValue(section, "Icon", GlobalVars.UserCustomization.Icon.ToString()); - ini.IniWriteValue(section, "Extra", GlobalVars.UserCustomization.Extra.ToString()); - - string section2 = "Colors"; - - ini.IniWriteValue(section2, "HeadColorID", GlobalVars.UserCustomization.HeadColorID.ToString()); - ini.IniWriteValue(section2, "HeadColorString", GlobalVars.UserCustomization.HeadColorString.ToString()); - ini.IniWriteValue(section2, "TorsoColorID", GlobalVars.UserCustomization.TorsoColorID.ToString()); - ini.IniWriteValue(section2, "TorsoColorString", GlobalVars.UserCustomization.TorsoColorString.ToString()); - ini.IniWriteValue(section2, "LeftArmColorID", GlobalVars.UserCustomization.LeftArmColorID.ToString()); - ini.IniWriteValue(section2, "LeftArmColorString", GlobalVars.UserCustomization.LeftArmColorString.ToString()); - ini.IniWriteValue(section2, "RightArmColorID", GlobalVars.UserCustomization.RightArmColorID.ToString()); - ini.IniWriteValue(section2, "RightArmColorString", GlobalVars.UserCustomization.RightArmColorString.ToString()); - ini.IniWriteValue(section2, "LeftLegColorID", GlobalVars.UserCustomization.LeftLegColorID.ToString()); - ini.IniWriteValue(section2, "LeftLegColorString", GlobalVars.UserCustomization.LeftLegColorString.ToString()); - ini.IniWriteValue(section2, "RightLegColorID", GlobalVars.UserCustomization.RightLegColorID.ToString()); - ini.IniWriteValue(section2, "RightLegColorString", GlobalVars.UserCustomization.RightLegColorString.ToString()); - - string section3 = "Other"; - - ini.IniWriteValue(section3, "CharacterID", GlobalVars.UserCustomization.CharacterID.ToString()); - ini.IniWriteValue(section3, "ExtraSelectionIsHat", GlobalVars.UserCustomization.ExtraSelectionIsHat.ToString()); - ini.IniWriteValue(section3, "ShowHatsOnExtra", GlobalVars.UserCustomization.ShowHatsInExtra.ToString()); - } - else - { - //READ - - try - { - string hat1, hat2, hat3, face, - head, tshirt, shirt, pants, icon, - extra, headcolorid, headcolorstring, torsocolorid, torsocolorstring, - larmid, larmstring, rarmid, rarmstring, llegid, - llegstring, rlegid, rlegstring, characterid, extraishat, showhatsonextra; - - INIFile ini = new INIFile(cfgpath); - - string section = "Items"; - - hat1 = ini.IniReadValue(section, "Hat1", GlobalVars.UserCustomization.Hat1.ToString()); - hat2 = ini.IniReadValue(section, "Hat2", GlobalVars.UserCustomization.Hat2.ToString()); - hat3 = ini.IniReadValue(section, "Hat3", GlobalVars.UserCustomization.Hat3.ToString()); - face = ini.IniReadValue(section, "Face", GlobalVars.UserCustomization.Face.ToString()); - head = ini.IniReadValue(section, "Head", GlobalVars.UserCustomization.Head.ToString()); - tshirt = ini.IniReadValue(section, "TShirt", GlobalVars.UserCustomization.TShirt.ToString()); - shirt = ini.IniReadValue(section, "Shirt", GlobalVars.UserCustomization.Shirt.ToString()); - pants = ini.IniReadValue(section, "Pants", GlobalVars.UserCustomization.Pants.ToString()); - icon = ini.IniReadValue(section, "Icon", GlobalVars.UserCustomization.Icon.ToString()); - extra = ini.IniReadValue(section, "Extra", GlobalVars.UserCustomization.Extra.ToString()); - - string section2 = "Colors"; - - headcolorid = ini.IniReadValue(section2, "HeadColorID", GlobalVars.UserCustomization.HeadColorID.ToString()); - headcolorstring = ini.IniReadValue(section2, "HeadColorString", GlobalVars.UserCustomization.HeadColorString.ToString()); - torsocolorid = ini.IniReadValue(section2, "TorsoColorID", GlobalVars.UserCustomization.TorsoColorID.ToString()); - torsocolorstring = ini.IniReadValue(section2, "TorsoColorString", GlobalVars.UserCustomization.TorsoColorString.ToString()); - larmid = ini.IniReadValue(section2, "LeftArmColorID", GlobalVars.UserCustomization.LeftArmColorID.ToString()); - larmstring = ini.IniReadValue(section2, "LeftArmColorString", GlobalVars.UserCustomization.LeftArmColorString.ToString()); - rarmid = ini.IniReadValue(section2, "RightArmColorID", GlobalVars.UserCustomization.RightArmColorID.ToString()); - rarmstring = ini.IniReadValue(section2, "RightArmColorString", GlobalVars.UserCustomization.RightArmColorString.ToString()); - llegid = ini.IniReadValue(section2, "LeftLegColorID", GlobalVars.UserCustomization.LeftLegColorID.ToString()); - llegstring = ini.IniReadValue(section2, "LeftLegColorString", GlobalVars.UserCustomization.LeftLegColorString.ToString()); - rlegid = ini.IniReadValue(section2, "RightLegColorID", GlobalVars.UserCustomization.RightLegColorID.ToString()); - rlegstring = ini.IniReadValue(section2, "RightLegColorString", GlobalVars.UserCustomization.RightLegColorString.ToString()); - - string section3 = "Other"; - - characterid = ini.IniReadValue(section3, "CharacterID", GlobalVars.UserCustomization.CharacterID.ToString()); - extraishat = ini.IniReadValue(section3, "ExtraSelectionIsHat", GlobalVars.UserCustomization.ExtraSelectionIsHat.ToString()); - showhatsonextra = ini.IniReadValue(section3, "ShowHatsOnExtra", GlobalVars.UserCustomization.ShowHatsInExtra.ToString()); - - FileFormat.CustomizationConfig DefaultCustomization = new FileFormat.CustomizationConfig(); - - GlobalVars.UserCustomization.Hat1 = hat1; - GlobalVars.UserCustomization.Hat2 = hat2; - GlobalVars.UserCustomization.Hat3 = hat3; - - GlobalVars.UserCustomization.HeadColorID = ValueInt(headcolorid, DefaultCustomization.HeadColorID); - GlobalVars.UserCustomization.TorsoColorID = ValueInt(torsocolorid, DefaultCustomization.TorsoColorID); - GlobalVars.UserCustomization.LeftArmColorID = ValueInt(larmid, DefaultCustomization.LeftArmColorID); - GlobalVars.UserCustomization.RightArmColorID = ValueInt(rarmid, DefaultCustomization.RightArmColorID); - GlobalVars.UserCustomization.LeftLegColorID = ValueInt(llegid, DefaultCustomization.LeftLegColorID); - GlobalVars.UserCustomization.RightLegColorID = ValueInt(rlegid, DefaultCustomization.RightArmColorID); - - GlobalVars.UserCustomization.HeadColorString = headcolorstring; - GlobalVars.UserCustomization.TorsoColorString = torsocolorstring; - GlobalVars.UserCustomization.LeftArmColorString = larmstring; - GlobalVars.UserCustomization.RightArmColorString = rarmstring; - GlobalVars.UserCustomization.LeftLegColorString = llegstring; - GlobalVars.UserCustomization.RightLegColorString = rlegstring; - - GlobalVars.UserCustomization.Face = face; - GlobalVars.UserCustomization.Head = head; - GlobalVars.UserCustomization.TShirt = tshirt; - GlobalVars.UserCustomization.Shirt = shirt; - GlobalVars.UserCustomization.Pants = pants; - GlobalVars.UserCustomization.Icon = icon; - - GlobalVars.UserCustomization.CharacterID = characterid; - GlobalVars.UserCustomization.Extra = extra; - GlobalVars.UserCustomization.ExtraSelectionIsHat = ValueBool(extraishat, DefaultCustomization.ExtraSelectionIsHat); - GlobalVars.UserCustomization.ShowHatsInExtra = ValueBool(showhatsonextra, DefaultCustomization.ShowHatsInExtra); - } - catch (Exception ex) - { - Util.LogExceptions(ex); - Customization(cfgpath, true); - } - } - - ReloadLoadoutValue(); - } - public static bool InitColors() { try @@ -1187,25 +889,25 @@ namespace Novetus.Core } #if LAUNCHER - public static void ResetConfigValues(Settings.Style style) + public static void ResetConfigValues(Settings.Style style) #else - public static void ResetConfigValues() + public static void ResetConfigValues() #endif { - bool WebProxySetupComplete = GlobalVars.UserConfiguration.WebProxyInitialSetupRequired; - bool WebProxy = GlobalVars.UserConfiguration.WebProxyEnabled; + bool WebProxySetupComplete = GlobalVars.UserConfiguration.ReadSettingBool("WebProxyInitialSetupRequired"); + bool WebProxy = GlobalVars.UserConfiguration.ReadSettingBool("WebProxyEnabled"); GlobalVars.UserConfiguration = new FileFormat.Config(); - GlobalVars.UserConfiguration.SelectedClient = GlobalVars.ProgramInformation.DefaultClient; - GlobalVars.UserConfiguration.Map = GlobalVars.ProgramInformation.DefaultMap; - GlobalVars.UserConfiguration.MapPath = GlobalPaths.MapsDir + @"\\" + GlobalVars.ProgramInformation.DefaultMap; - GlobalVars.UserConfiguration.MapPathSnip = GlobalPaths.MapsDirBase + @"\\" + GlobalVars.ProgramInformation.DefaultMap; + 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); #if LAUNCHER - GlobalVars.UserConfiguration.LauncherStyle = style; + GlobalVars.UserConfiguration.SaveSettingInt("LauncherStyle", (int)style); #endif - GlobalVars.UserConfiguration.WebProxyInitialSetupRequired = WebProxySetupComplete; - GlobalVars.UserConfiguration.WebProxyEnabled = WebProxy; - NovetusFuncs.GeneratePlayerID(); + GlobalVars.UserConfiguration.SaveSettingBool("WebProxyInitialSetupRequired", WebProxySetupComplete); + GlobalVars.UserConfiguration.SaveSettingBool("WebProxyEnabled", WebProxy); + GlobalVars.UserConfiguration.SaveSettingInt("UserID", NovetusFuncs.GeneratePlayerID()); ResetCustomizationValues(); } @@ -1214,6 +916,7 @@ namespace Novetus.Core GlobalVars.UserCustomization = new FileFormat.CustomizationConfig(); ReloadLoadoutValue(); } + public static string GetItemTextureLocalPath(string item, string nameprefix) { //don't bother, we're offline. @@ -1302,51 +1005,42 @@ namespace Novetus.Core public static void ReloadLoadoutValue(bool localizeOnlineClothing = false) { - string hat1 = (!GlobalVars.UserCustomization.Hat1.EndsWith("-Solo.rbxm")) ? GlobalVars.UserCustomization.Hat1 : "NoHat.rbxm"; - string hat2 = (!GlobalVars.UserCustomization.Hat2.EndsWith("-Solo.rbxm")) ? GlobalVars.UserCustomization.Hat2 : "NoHat.rbxm"; - string hat3 = (!GlobalVars.UserCustomization.Hat3.EndsWith("-Solo.rbxm")) ? GlobalVars.UserCustomization.Hat3 : "NoHat.rbxm"; - string extra = (!GlobalVars.UserCustomization.Extra.EndsWith("-Solo.rbxm")) ? GlobalVars.UserCustomization.Extra : "NoExtra.rbxm"; + string hat1 = (!GlobalVars.UserCustomization.ReadSetting("Hat1").EndsWith("-Solo.rbxm")) ? GlobalVars.UserCustomization.ReadSetting("Hat1") : "NoHat.rbxm"; + string hat2 = (!GlobalVars.UserCustomization.ReadSetting("Hat2").EndsWith("-Solo.rbxm")) ? GlobalVars.UserCustomization.ReadSetting("Hat2") : "NoHat.rbxm"; + string hat3 = (!GlobalVars.UserCustomization.ReadSetting("Hat3").EndsWith("-Solo.rbxm")) ? GlobalVars.UserCustomization.ReadSetting("Hat3") : "NoHat.rbxm"; + string extra = (!GlobalVars.UserCustomization.ReadSetting("Extra").EndsWith("-Solo.rbxm")) ? GlobalVars.UserCustomization.ReadSetting("Extra") : "NoExtra.rbxm"; + + string baseClothing = GlobalVars.UserCustomization.ReadSettingInt("HeadColorID") + "," + + GlobalVars.UserCustomization.ReadSettingInt("TorsoColorID") + "," + + GlobalVars.UserCustomization.ReadSettingInt("LeftArmColorID") + "," + + GlobalVars.UserCustomization.ReadSettingInt("RightArmColorID") + "," + + GlobalVars.UserCustomization.ReadSettingInt("LeftLegColorID") + "," + + GlobalVars.UserCustomization.ReadSettingInt("RightLegColorID") + ",'" + + GlobalVars.UserCustomization.ReadSetting("TShirt") + "','" + + GlobalVars.UserCustomization.ReadSetting("Shirt") + "','" + + GlobalVars.UserCustomization.ReadSetting("Pants") + "','" + + GlobalVars.UserCustomization.ReadSetting("Face") + "','" + + GlobalVars.UserCustomization.ReadSetting("Head") + "','" + + GlobalVars.UserCustomization.ReadSetting("Icon") + "','"; GlobalVars.Loadout = "'" + hat1 + "','" + hat2 + "','" + hat3 + "'," + - GlobalVars.UserCustomization.HeadColorID + "," + - GlobalVars.UserCustomization.TorsoColorID + "," + - GlobalVars.UserCustomization.LeftArmColorID + "," + - GlobalVars.UserCustomization.RightArmColorID + "," + - GlobalVars.UserCustomization.LeftLegColorID + "," + - GlobalVars.UserCustomization.RightLegColorID + ",'" + - GlobalVars.UserCustomization.TShirt + "','" + - GlobalVars.UserCustomization.Shirt + "','" + - GlobalVars.UserCustomization.Pants + "','" + - GlobalVars.UserCustomization.Face + "','" + - GlobalVars.UserCustomization.Head + "','" + - GlobalVars.UserCustomization.Icon + "','" + + baseClothing + extra + "'"; - GlobalVars.soloLoadout = "'" + GlobalVars.UserCustomization.Hat1 + "','" + - GlobalVars.UserCustomization.Hat2 + "','" + - GlobalVars.UserCustomization.Hat3 + "'," + - GlobalVars.UserCustomization.HeadColorID + "," + - GlobalVars.UserCustomization.TorsoColorID + "," + - GlobalVars.UserCustomization.LeftArmColorID + "," + - GlobalVars.UserCustomization.RightArmColorID + "," + - GlobalVars.UserCustomization.LeftLegColorID + "," + - GlobalVars.UserCustomization.RightLegColorID + ",'" + - GlobalVars.UserCustomization.TShirt + "','" + - GlobalVars.UserCustomization.Shirt + "','" + - GlobalVars.UserCustomization.Pants + "','" + - GlobalVars.UserCustomization.Face + "','" + - GlobalVars.UserCustomization.Head + "','" + - GlobalVars.UserCustomization.Icon + "','" + - GlobalVars.UserCustomization.Extra + "'"; + GlobalVars.soloLoadout = "'" + GlobalVars.UserCustomization.ReadSetting("Hat1") + "','" + + GlobalVars.UserCustomization.ReadSetting("Hat2") + "','" + + GlobalVars.UserCustomization.ReadSetting("Hat3") + "'," + + baseClothing + + GlobalVars.UserCustomization.ReadSetting("Extra") + "'"; if (localizeOnlineClothing) { - GlobalVars.TShirtTextureID = GetItemTextureID(GlobalVars.UserCustomization.TShirt, "TShirt", new AssetCacheDefBasic("ShirtGraphic", new string[] { "Graphic" })); - GlobalVars.ShirtTextureID = GetItemTextureID(GlobalVars.UserCustomization.Shirt, "Shirt", new AssetCacheDefBasic("Shirt", new string[] { "ShirtTemplate" })); - GlobalVars.PantsTextureID = GetItemTextureID(GlobalVars.UserCustomization.Pants, "Pants", new AssetCacheDefBasic("Pants", new string[] { "PantsTemplate" })); - GlobalVars.FaceTextureID = GetItemTextureID(GlobalVars.UserCustomization.Face, "Face", new AssetCacheDefBasic("Decal", new string[] { "Texture" })); + GlobalVars.TShirtTextureID = GetItemTextureID(GlobalVars.UserCustomization.ReadSetting("TShirt"), "TShirt", new AssetCacheDefBasic("ShirtGraphic", new string[] { "Graphic" })); + GlobalVars.ShirtTextureID = GetItemTextureID(GlobalVars.UserCustomization.ReadSetting("Shirt"), "Shirt", new AssetCacheDefBasic("Shirt", new string[] { "ShirtTemplate" })); + GlobalVars.PantsTextureID = GetItemTextureID(GlobalVars.UserCustomization.ReadSetting("Pants"), "Pants", new AssetCacheDefBasic("Pants", new string[] { "PantsTemplate" })); + GlobalVars.FaceTextureID = GetItemTextureID(GlobalVars.UserCustomization.ReadSetting("Face"), "Face", new AssetCacheDefBasic("Decal", new string[] { "Texture" })); GlobalVars.TShirtTextureLocal = GetItemTextureLocalPath(GlobalVars.TShirtTextureID, "TShirt"); GlobalVars.ShirtTextureLocal = GetItemTextureLocalPath(GlobalVars.ShirtTextureID, "Shirt"); diff --git a/Novetus/NovetusCore/StorageAndFunctions/GlobalPaths.cs b/Novetus/NovetusCore/StorageAndFunctions/GlobalPaths.cs index bd39b52..52e1914 100644 --- a/Novetus/NovetusCore/StorageAndFunctions/GlobalPaths.cs +++ b/Novetus/NovetusCore/StorageAndFunctions/GlobalPaths.cs @@ -13,7 +13,11 @@ namespace Novetus.Core public static readonly string RootPathLauncher = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); public static readonly string BasePathLauncher = RootPathLauncher.Replace(@"\", @"\\"); public static readonly string RootPath = Directory.GetParent(RootPathLauncher).ToString(); +#if BASICLAUNCHER + public static readonly string BasePath = BasePathLauncher; +#else public static readonly string BasePath = RootPath.Replace(@"\", @"\\"); +#endif public static readonly string DataPath = BasePath + @"\\shareddata"; public static readonly string AssetsPath = BasePath + @"\\assets"; public static readonly string BinDir = BasePath + @"\\bin"; @@ -21,7 +25,7 @@ namespace Novetus.Core public static readonly string LogDir = BasePath + @"\\logs"; public static readonly string ConfigDirClients = ConfigDir + @"\\clients"; public static readonly string ConfigDirTemplates = ConfigDir + @"\\itemtemplates"; - public static readonly string DataDir = BinDir + @"\\data"; + public static readonly string DataDir = ConfigDir + @"\\launcherdata"; public static readonly string ClientDir = BasePath + @"\\clients"; public static readonly string MapsDir = BasePath + @"\\maps"; public static readonly string AddonDir = BasePath + @"\\addons"; @@ -34,9 +38,9 @@ namespace Novetus.Core public static readonly string BaseGameDir = "rbxasset://../../../"; public static readonly string AltBaseGameDir = "rbxasset://"; public static readonly string SharedDataGameDir = BaseGameDir + "shareddata/"; - #endregion +#endregion - #region Customization Paths +#region Customization Paths public static readonly string CustomPlayerDir = DataPath + "\\charcustom"; public static readonly string hatdir = CustomPlayerDir + "\\hats"; public static readonly string facedir = CustomPlayerDir + "\\faces"; @@ -55,11 +59,11 @@ namespace Novetus.Core public static readonly string shirtGameDir = CharCustomGameDir + "shirts/"; public static readonly string pantsGameDir = CharCustomGameDir + "pants/"; public static readonly string extraGameDir = CharCustomGameDir + "custom/"; - #endregion +#endregion - #region Asset Cache Paths +#region Asset Cache Paths - #region Base Paths +#region Base Paths public static readonly string DirFonts = "\\fonts"; public static readonly string DirSounds = "\\sounds"; public static readonly string DirTextures = "\\textures"; @@ -68,17 +72,17 @@ namespace Novetus.Core public static readonly string SoundsGameDir = "sounds/"; public static readonly string TexturesGameDir = "textures/"; public static readonly string ScriptsGameDir = "scripts/"; - #endregion +#endregion - #region Asset Dirs +#region Asset Dirs public static string AssetCacheDir = DataPath + "\\assetcache"; public static string AssetCacheDirAssets = AssetCacheDir + "\\assets"; public static string AssetCacheGameDir = SharedDataGameDir + "assetcache/"; public static string AssetCacheAssetsGameDir = AssetCacheGameDir + "assets/"; - #endregion +#endregion - #region Item Dirs +#region Item Dirs public static readonly string hatdirFonts = hatdir + DirFonts; public static readonly string hatdirTextures = hatdir + DirTextures; public static readonly string hatdirSounds = hatdir + DirSounds; @@ -100,11 +104,11 @@ namespace Novetus.Core public static readonly string tshirtGameDirTextures = tshirtGameDir; //+ TexturesGameDir; public static readonly string shirtGameDirTextures = shirtGameDir + TexturesGameDir; public static readonly string pantsGameDirTextures = pantsGameDir + TexturesGameDir; - #endregion +#endregion - #endregion +#endregion - #region File Names +#region File Names public static readonly string ConfigName = "config.ini"; public static string ConfigNameCustomization = "config_customization.ini"; public static readonly string InfoName = "info.ini"; @@ -120,7 +124,7 @@ namespace Novetus.Core public static readonly string AddonLoaderFileName = "AddonLoader.lua"; public static readonly string AssetFixerPatternFileName = "assetfixer_pattern.txt"; public static readonly string TermListFileName = "term-list.txt"; - #endregion +#endregion } - #endregion +#endregion } diff --git a/Novetus/NovetusCore/StorageAndFunctions/NetFuncs.cs b/Novetus/NovetusCore/StorageAndFunctions/NetFuncs.cs index 125240a..46247ab 100644 --- a/Novetus/NovetusCore/StorageAndFunctions/NetFuncs.cs +++ b/Novetus/NovetusCore/StorageAndFunctions/NetFuncs.cs @@ -14,7 +14,7 @@ namespace Novetus.Core { public static void InitUPnP() { - if (GlobalVars.UserConfiguration.UPnP) + if (GlobalVars.UserConfiguration.ReadSettingBool("UPnP")) { try { @@ -35,10 +35,10 @@ namespace Novetus.Core try { INatDevice device = args.Device; - string IP = !string.IsNullOrWhiteSpace(GlobalVars.UserConfiguration.AlternateServerIP) ? GlobalVars.UserConfiguration.AlternateServerIP : device.GetExternalIP().ToString(); + string IP = !string.IsNullOrWhiteSpace(GlobalVars.UserConfiguration.ReadSetting("AlternateServerIP")) ? GlobalVars.UserConfiguration.ReadSetting("AlternateServerIP") : device.GetExternalIP().ToString(); Util.ConsolePrint("UPnP: Device '" + IP + "' registered.", 3); - StartUPnP(device, Protocol.Udp, GlobalVars.UserConfiguration.RobloxPort); - StartUPnP(device, Protocol.Tcp, GlobalVars.UserConfiguration.RobloxPort); + StartUPnP(device, Protocol.Udp, GlobalVars.UserConfiguration.ReadSettingInt("RobloxPort")); + StartUPnP(device, Protocol.Tcp, GlobalVars.UserConfiguration.ReadSettingInt("RobloxPort")); } catch (Exception ex) { @@ -49,7 +49,7 @@ namespace Novetus.Core public static void StartUPnP(INatDevice device, Protocol protocol, int port) { - if (GlobalVars.UserConfiguration.UPnP) + if (GlobalVars.UserConfiguration.ReadSettingBool("UPnP")) { try { @@ -63,7 +63,7 @@ namespace Novetus.Core device.CreatePortMap(portmap); } - string IP = !string.IsNullOrWhiteSpace(GlobalVars.UserConfiguration.AlternateServerIP) ? GlobalVars.UserConfiguration.AlternateServerIP : device.GetExternalIP().ToString(); + string IP = !string.IsNullOrWhiteSpace(GlobalVars.UserConfiguration.ReadSetting("AlternateServerIP")) ? GlobalVars.UserConfiguration.ReadSetting("AlternateServerIP") : device.GetExternalIP().ToString(); Util.ConsolePrint("UPnP: Port " + port + " opened on '" + IP + "' (" + protocol.ToString() + ")", 3); } catch (Exception ex) @@ -76,7 +76,7 @@ namespace Novetus.Core public static void StopUPnP(INatDevice device, Protocol protocol, int port) { - if (GlobalVars.UserConfiguration.UPnP) + if (GlobalVars.UserConfiguration.ReadSettingBool("UPnP")) { try { @@ -90,7 +90,7 @@ namespace Novetus.Core device.DeletePortMap(portmap); } - string IP = !string.IsNullOrWhiteSpace(GlobalVars.UserConfiguration.AlternateServerIP) ? GlobalVars.UserConfiguration.AlternateServerIP : device.GetExternalIP().ToString(); + string IP = !string.IsNullOrWhiteSpace(GlobalVars.UserConfiguration.ReadSetting("AlternateServerIP")) ? GlobalVars.UserConfiguration.ReadSetting("AlternateServerIP") : device.GetExternalIP().ToString(); Util.ConsolePrint("UPnP: Port " + port + " closed on '" + IP + "' (" + protocol.ToString() + ")", 3); } catch (Exception ex) diff --git a/Novetus/NovetusCore/StorageAndFunctions/NovetusFuncs.cs b/Novetus/NovetusCore/StorageAndFunctions/NovetusFuncs.cs index 169d4c5..0b27455 100644 --- a/Novetus/NovetusCore/StorageAndFunctions/NovetusFuncs.cs +++ b/Novetus/NovetusCore/StorageAndFunctions/NovetusFuncs.cs @@ -63,11 +63,9 @@ namespace Novetus.Core return randomID; } - public static void GeneratePlayerID() + public static int GeneratePlayerID() { - int randomID = GenerateRandomNumber(); - //2147483647 is max id. - GlobalVars.UserConfiguration.UserID = randomID; + return GenerateRandomNumber(); } public static void PingMasterServer(bool online, string reason) @@ -75,29 +73,31 @@ namespace Novetus.Core if (GlobalVars.GameOpened == ScriptType.Server || GlobalVars.GameOpened == ScriptType.EasterEggServer) return; - if (string.IsNullOrWhiteSpace(GlobalVars.UserConfiguration.ServerBrowserServerAddress)) + if (string.IsNullOrWhiteSpace(GlobalVars.UserConfiguration.ReadSetting("ServerBrowserServerAddress"))) return; - if (string.IsNullOrWhiteSpace(GlobalVars.UserConfiguration.ServerBrowserServerName)) + if (string.IsNullOrWhiteSpace(GlobalVars.UserConfiguration.ReadSetting("ServerBrowserServerName"))) { Util.ConsolePrint("Your server doesn't have a name. Please specify one for it to show on the master server list after server restart.", 2); return; } + string AlternateServerIP = GlobalVars.UserConfiguration.ReadSetting("AlternateServerIP"); + if (online) { GlobalVars.ServerID = RandomString(30) + GenerateRandomNumber(); - GlobalVars.PingURL = "http://" + GlobalVars.UserConfiguration.ServerBrowserServerAddress + - "/list.php?name=" + GlobalVars.UserConfiguration.ServerBrowserServerName + - "&ip=" + (!string.IsNullOrWhiteSpace(GlobalVars.UserConfiguration.AlternateServerIP) ? GlobalVars.UserConfiguration.AlternateServerIP : GlobalVars.ExternalIP) + - "&port=" + GlobalVars.UserConfiguration.RobloxPort + - "&client=" + GlobalVars.UserConfiguration.SelectedClient + + GlobalVars.PingURL = "http://" + GlobalVars.UserConfiguration.ReadSetting("ServerBrowserServerAddress") + + "/list.php?name=" + GlobalVars.UserConfiguration.ReadSetting("ServerBrowserServerName") + + "&ip=" + (!string.IsNullOrWhiteSpace(AlternateServerIP) ? AlternateServerIP : GlobalVars.ExternalIP) + + "&port=" + GlobalVars.UserConfiguration.ReadSettingInt("RobloxPort") + + "&client=" + GlobalVars.UserConfiguration.ReadSetting("SelectedClient") + "&version=" + GlobalVars.ProgramInformation.Version + "&id=" + GlobalVars.ServerID; } else { - GlobalVars.PingURL = "http://" + GlobalVars.UserConfiguration.ServerBrowserServerAddress + + GlobalVars.PingURL = "http://" + GlobalVars.UserConfiguration.ReadSetting("ServerBrowserServerAddress") + "/delist.php?id=" + GlobalVars.ServerID; GlobalVars.ServerID = "N/A"; } @@ -127,25 +127,28 @@ namespace Novetus.Core public static string[] LoadServerInformation() { + string AlternateServerIP = GlobalVars.UserConfiguration.ReadSetting("AlternateServerIP"); + int RobloxPort = GlobalVars.UserConfiguration.ReadSettingInt("RobloxPort"); + string SelectedClient = GlobalVars.UserConfiguration.ReadSetting("SelectedClient"); + string[] lines1 = { - SecurityFuncs.Encode(!string.IsNullOrWhiteSpace(GlobalVars.UserConfiguration.AlternateServerIP) ? GlobalVars.UserConfiguration.AlternateServerIP : GlobalVars.ExternalIP), - SecurityFuncs.Encode(GlobalVars.UserConfiguration.RobloxPort.ToString()), - SecurityFuncs.Encode(GlobalVars.UserConfiguration.SelectedClient) + SecurityFuncs.Encode(!string.IsNullOrWhiteSpace(AlternateServerIP) ? AlternateServerIP : GlobalVars.ExternalIP), + SecurityFuncs.Encode(RobloxPort.ToString()), + SecurityFuncs.Encode(SelectedClient) }; string URI = "novetus://" + SecurityFuncs.Encode(string.Join("|", lines1), true); string[] lines2 = { SecurityFuncs.Encode("localhost"), - SecurityFuncs.Encode(GlobalVars.UserConfiguration.RobloxPort.ToString()), - SecurityFuncs.Encode(GlobalVars.UserConfiguration.SelectedClient) + SecurityFuncs.Encode(RobloxPort.ToString()), + SecurityFuncs.Encode(SelectedClient) }; string URI2 = "novetus://" + SecurityFuncs.Encode(string.Join("|", lines2), true); - GameServer server = new GameServer((!string.IsNullOrWhiteSpace(GlobalVars.UserConfiguration.AlternateServerIP) ? GlobalVars.UserConfiguration.AlternateServerIP : GlobalVars.ExternalIP), - GlobalVars.UserConfiguration.RobloxPort); + GameServer server = new GameServer((!string.IsNullOrWhiteSpace(AlternateServerIP) ? AlternateServerIP : GlobalVars.ExternalIP), RobloxPort); string[] text = { "Server IP Address: " + server.ToString(), - "Client: " + GlobalVars.UserConfiguration.SelectedClient, - "Map: " + GlobalVars.UserConfiguration.Map, - "Players: " + GlobalVars.UserConfiguration.PlayerLimit, + "Client: " + SelectedClient, + "Map: " + GlobalVars.UserConfiguration.ReadSetting("Map"), + "Players: " + GlobalVars.UserConfiguration.ReadSettingInt("PlayerLimit"), "Version: Novetus " + GlobalVars.ProgramInformation.Version, "Online URI Link:", URI, @@ -173,7 +176,7 @@ namespace Novetus.Core } } - switch (GlobalVars.UserConfiguration.LauncherStyle) + switch ((Settings.Style)GlobalVars.UserConfiguration.ReadSettingInt("LauncherStyle")) { case Settings.Style.Extended: CharacterCustomizationExtended ccustom = new CharacterCustomizationExtended(); diff --git a/Novetus/NovetusLauncher/Classes/Launcher/SplashLoader.cs b/Novetus/NovetusLauncher/Classes/Launcher/SplashLoader.cs index 89e0988..0dde022 100644 --- a/Novetus/NovetusLauncher/Classes/Launcher/SplashLoader.cs +++ b/Novetus/NovetusLauncher/Classes/Launcher/SplashLoader.cs @@ -156,8 +156,8 @@ public class Splash CryptoRandom random = new CryptoRandom(); DateTime now = DateTime.Now; - return text.Replace("%name%", GlobalVars.UserConfiguration.PlayerName) - .Replace("%randomtext%", NovetusFuncs.RandomString(random.Next(2, (GlobalVars.UserConfiguration.LauncherStyle == Settings.Style.Stylish ? 64 : 32)))) + return text.Replace("%name%", GlobalVars.UserConfiguration.ReadSetting("PlayerName")) + .Replace("%randomtext%", NovetusFuncs.RandomString(random.Next(2, (GlobalVars.UserConfiguration.ReadSettingInt("LauncherStyle") == (int)Settings.Style.Stylish ? 64 : 32)))) .Replace("%version%", GlobalVars.ProgramInformation.Version) .Replace("%year%", now.Year.ToString()) .Replace("%day%", now.Day.ToString()) @@ -265,14 +265,14 @@ public static class SplashReader { if (specialsplash.Compatibility == SplashCompatibility.Stylish) { - if (GlobalVars.UserConfiguration.LauncherStyle != Settings.Style.Stylish) + if (GlobalVars.UserConfiguration.ReadSettingInt("LauncherStyle") != (int)Settings.Style.Stylish) { continue; } } else if (specialsplash.Compatibility == SplashCompatibility.Normal) { - if (GlobalVars.UserConfiguration.LauncherStyle == Settings.Style.Stylish) + if (GlobalVars.UserConfiguration.ReadSettingInt("LauncherStyle") == (int)Settings.Style.Stylish) { continue; } @@ -353,7 +353,7 @@ public static class SplashReader { if (generatedSplash.Compatibility == SplashCompatibility.Stylish) { - if (GlobalVars.UserConfiguration.LauncherStyle == Settings.Style.Stylish) + if (GlobalVars.UserConfiguration.ReadSettingInt("LauncherStyle") == (int)Settings.Style.Stylish) { checkStylishSplash = false; } @@ -364,7 +364,7 @@ public static class SplashReader } else if (generatedSplash.Compatibility == SplashCompatibility.Normal) { - if (GlobalVars.UserConfiguration.LauncherStyle != Settings.Style.Stylish) + if (GlobalVars.UserConfiguration.ReadSettingInt("LauncherStyle") != (int)Settings.Style.Stylish) { checkStylishSplash = false; } diff --git a/Novetus/NovetusLauncher/Forms/CustomGraphicsOptions.cs b/Novetus/NovetusLauncher/Forms/CustomGraphicsOptions.cs index 50d46e5..35997a4 100644 --- a/Novetus/NovetusLauncher/Forms/CustomGraphicsOptions.cs +++ b/Novetus/NovetusLauncher/Forms/CustomGraphicsOptions.cs @@ -41,10 +41,12 @@ namespace NovetusLauncher #region Form Events private void CustomGraphicsOptions_Load(object sender, EventArgs e) { - ClientManagement.ReadClientValues(GlobalVars.UserConfiguration.SelectedClient); - info = ClientManagement.GetClientInfoValues(GlobalVars.UserConfiguration.SelectedClient); + string client = GlobalVars.UserConfiguration.ReadSetting("SelectedClient"); - string terms = "_" + GlobalVars.UserConfiguration.SelectedClient; + ClientManagement.ReadClientValues(client); + info = ClientManagement.GetClientInfoValues(client); + + string terms = "_" + client; bool hasFoundDir = false; string[] dirs = Directory.GetFiles(GlobalPaths.ConfigDirClients); @@ -423,12 +425,12 @@ namespace NovetusLauncher private void Style2007FolderFinder_Click(object sender, EventArgs e) { - Process.Start("explorer.exe", GlobalPaths.ClientDir.Replace(@"\\", @"\") + @"\" + GlobalVars.UserConfiguration.SelectedClient + @"\Styles"); + Process.Start("explorer.exe", GlobalPaths.ClientDir.Replace(@"\\", @"\") + @"\" + GlobalVars.UserConfiguration.ReadSetting("SelectedClient") + @"\Styles"); } private void Styles2007Info_Click(object sender, EventArgs e) { - MessageBox.Show("Make sure you place the styles you want in the Styles folder in " + GlobalPaths.ClientDir.Replace(@"\\", @"\") + @"\" + GlobalVars.UserConfiguration.SelectedClient + @"\Styles." + Environment.NewLine + "If the files are not placed in this directory, they will not be loaded properly.\nThis client will accept .msstyles and .cjstyles files.", "Novetus - Styles Help", MessageBoxButtons.OK, MessageBoxIcon.Information); + MessageBox.Show("Make sure you place the styles you want in the Styles folder in " + GlobalPaths.ClientDir.Replace(@"\\", @"\") + @"\" + GlobalVars.UserConfiguration.ReadSetting("SelectedClient") + @"\Styles." + Environment.NewLine + "If the files are not placed in this directory, they will not be loaded properly.\nThis client will accept .msstyles and .cjstyles files.", "Novetus - Styles Help", MessageBoxButtons.OK, MessageBoxIcon.Information); } private void GraphicsShadows2007_SelectedIndexChanged(object sender, EventArgs e) @@ -446,10 +448,12 @@ namespace NovetusLauncher private void CustomGraphicsOptions_Close(object sender, FormClosingEventArgs e) { - ClientManagement.ReadClientValues(GlobalVars.UserConfiguration.SelectedClient); - ClientManagement.ApplyClientSettings_custom(info, GlobalVars.UserConfiguration.SelectedClient, MeshDetail, ShadingQuality, MaterialQuality, - AA, AASamples, Bevels, Shadows_2008, Shadows_2007, Style_2007, QualityLevel, - WindowResolution, FullscreenResolution, ModernResolution); + string client = GlobalVars.UserConfiguration.ReadSetting("SelectedClient"); + ClientManagement.ReadClientValues(client); + ClientManagement.ApplyClientSettings_custom(info, client, + MeshDetail, ShadingQuality, MaterialQuality, + AA, AASamples, Bevels, Shadows_2008, Shadows_2007, Style_2007, QualityLevel, + WindowResolution, FullscreenResolution, ModernResolution); } #endregion diff --git a/Novetus/NovetusLauncher/Forms/LauncherForm/Compact/LauncherFormCompact.Designer.cs b/Novetus/NovetusLauncher/Forms/LauncherForm/Compact/LauncherFormCompact.Designer.cs index c9d1138..f24e4cc 100644 --- a/Novetus/NovetusLauncher/Forms/LauncherForm/Compact/LauncherFormCompact.Designer.cs +++ b/Novetus/NovetusLauncher/Forms/LauncherForm/Compact/LauncherFormCompact.Designer.cs @@ -1405,7 +1405,7 @@ namespace NovetusLauncher launcherForm.ProductVersionLabel = label8; launcherForm.NovetusVersionLabel = label11; launcherForm.CloseOnLaunchCheckbox = checkBox1; - launcherForm.DiscordPresenceCheckbox = checkBox2; + launcherForm.DiscordRichPresenceCheckbox = checkBox2; launcherForm.uPnPCheckBox = checkBox4; launcherForm.ShowServerNotifsCheckBox = checkBox9; launcherForm.PlayerIDTextBox = textBox5; diff --git a/Novetus/NovetusLauncher/Forms/LauncherForm/Compact/LauncherFormCompact.cs b/Novetus/NovetusLauncher/Forms/LauncherForm/Compact/LauncherFormCompact.cs index 94ed02a..127761c 100644 --- a/Novetus/NovetusLauncher/Forms/LauncherForm/Compact/LauncherFormCompact.cs +++ b/Novetus/NovetusLauncher/Forms/LauncherForm/Compact/LauncherFormCompact.cs @@ -225,7 +225,7 @@ namespace NovetusLauncher private void checkBox2_CheckedChanged(object sender, EventArgs e) { - GlobalVars.UserConfiguration.DiscordPresence = checkBox2.Checked; + GlobalVars.UserConfiguration.DiscordRichPresence = checkBox2.Checked; } void CheckBox2Click(object sender, EventArgs e) diff --git a/Novetus/NovetusLauncher/Forms/LauncherForm/Extended/LauncherFormExtended.Designer.cs b/Novetus/NovetusLauncher/Forms/LauncherForm/Extended/LauncherFormExtended.Designer.cs index a70ad78..2dd14c1 100644 --- a/Novetus/NovetusLauncher/Forms/LauncherForm/Extended/LauncherFormExtended.Designer.cs +++ b/Novetus/NovetusLauncher/Forms/LauncherForm/Extended/LauncherFormExtended.Designer.cs @@ -1368,7 +1368,7 @@ namespace NovetusLauncher launcherForm.ProductVersionLabel = label8; launcherForm.NovetusVersionLabel = label11; launcherForm.CloseOnLaunchCheckbox = checkBox1; - launcherForm.DiscordPresenceCheckbox = checkBox2; + launcherForm.DiscordRichPresenceCheckbox = checkBox2; launcherForm.uPnPCheckBox = checkBox4; launcherForm.ShowServerNotifsCheckBox = checkBox9; launcherForm.PlayerIDTextBox = textBox5; diff --git a/Novetus/NovetusLauncher/Forms/LauncherForm/Extended/LauncherFormExtended.cs b/Novetus/NovetusLauncher/Forms/LauncherForm/Extended/LauncherFormExtended.cs index 3a8d06c..f612810 100644 --- a/Novetus/NovetusLauncher/Forms/LauncherForm/Extended/LauncherFormExtended.cs +++ b/Novetus/NovetusLauncher/Forms/LauncherForm/Extended/LauncherFormExtended.cs @@ -234,7 +234,7 @@ namespace NovetusLauncher private void checkBox2_CheckedChanged(object sender, EventArgs e) { - GlobalVars.UserConfiguration.DiscordPresence = checkBox2.Checked; + GlobalVars.UserConfiguration.DiscordRichPresence = checkBox2.Checked; } void CheckBox2Click(object sender, EventArgs e) diff --git a/Novetus/NovetusLauncher/Forms/LauncherForm/LauncherFormShared.cs b/Novetus/NovetusLauncher/Forms/LauncherForm/LauncherFormShared.cs index 34363f3..5585d27 100644 --- a/Novetus/NovetusLauncher/Forms/LauncherForm/LauncherFormShared.cs +++ b/Novetus/NovetusLauncher/Forms/LauncherForm/LauncherFormShared.cs @@ -58,7 +58,7 @@ namespace NovetusLauncher public Label SplashLabel, ProductVersionLabel, NovetusVersionLabel, PlayerTripcodeLabel, IPLabel, PortLabel, SelectedClientLabel, SelectedMapLabel, ClientWarningLabel = null; public ComboBox StyleSelectorBox = null; - public CheckBox CloseOnLaunchCheckbox, DiscordPresenceCheckbox, uPnPCheckBox, ShowServerNotifsCheckBox, LocalPlayCheckBox = null; + public CheckBox CloseOnLaunchCheckbox, DiscordRichPresenceCheckbox, uPnPCheckBox, ShowServerNotifsCheckBox, LocalPlayCheckBox = null; public Button RegeneratePlayerIDButton = null; public NumericUpDown PlayerLimitBox, HostPortBox = null; public string TabPageHost, TabPageMaps, TabPageClients, TabPageSaved, OldIP = ""; @@ -175,7 +175,7 @@ namespace NovetusLauncher { WriteConfigValues(); } - if (GlobalVars.UserConfiguration.DiscordPresence) + if (GlobalVars.UserConfiguration.DiscordRichPresence) { IDiscordRPC.Shutdown(); } @@ -595,7 +595,7 @@ namespace NovetusLauncher HostPortBox.Value = Convert.ToDecimal(GlobalVars.UserConfiguration.RobloxPort); IPLabel.Text = GlobalVars.CurrentServer.ServerIP; PortLabel.Text = GlobalVars.CurrentServer.ServerPort.ToString(); - DiscordPresenceCheckbox.Checked = GlobalVars.UserConfiguration.DiscordPresence; + DiscordRichPresenceCheckbox.Checked = GlobalVars.UserConfiguration.DiscordRichPresence; uPnPCheckBox.Checked = GlobalVars.UserConfiguration.UPnP; ShowServerNotifsCheckBox.Checked = GlobalVars.UserConfiguration.ShowServerNotifications; ServerBrowserNameBox.Text = GlobalVars.UserConfiguration.ServerBrowserServerName; diff --git a/Novetus/NovetusLauncher/Forms/LauncherForm/Stylish/LauncherFormStylish.cs b/Novetus/NovetusLauncher/Forms/LauncherForm/Stylish/LauncherFormStylish.cs index bd55d07..97d496e 100644 --- a/Novetus/NovetusLauncher/Forms/LauncherForm/Stylish/LauncherFormStylish.cs +++ b/Novetus/NovetusLauncher/Forms/LauncherForm/Stylish/LauncherFormStylish.cs @@ -121,7 +121,7 @@ namespace NovetusLauncher launcherFormStylishInterface1.mapsBox.SelectedNode.ForeColor = SystemColors.HighlightText; } launcherFormStylishInterface1.serverPortBox.Text = GlobalVars.UserConfiguration.RobloxPort.ToString(); - launcherFormStylishInterface1.discordRichPresenceBox.IsChecked = GlobalVars.UserConfiguration.DiscordPresence; + launcherFormStylishInterface1.discordRichPresenceBox.IsChecked = GlobalVars.UserConfiguration.DiscordRichPresence; launcherFormStylishInterface1.uPnPBox.IsChecked = GlobalVars.UserConfiguration.UPnP; launcherFormStylishInterface1.NotifBox.IsChecked = GlobalVars.UserConfiguration.ShowServerNotifications; launcherFormStylishInterface1.browserNameBox.Text = GlobalVars.UserConfiguration.ServerBrowserServerName; diff --git a/Novetus/NovetusLauncher/Forms/LauncherForm/Stylish/LauncherFormStylishInterface.xaml.cs b/Novetus/NovetusLauncher/Forms/LauncherForm/Stylish/LauncherFormStylishInterface.xaml.cs index 799cf61..120b502 100644 --- a/Novetus/NovetusLauncher/Forms/LauncherForm/Stylish/LauncherFormStylishInterface.xaml.cs +++ b/Novetus/NovetusLauncher/Forms/LauncherForm/Stylish/LauncherFormStylishInterface.xaml.cs @@ -390,14 +390,14 @@ namespace NovetusLauncher { if (!IsLoaded) return; - GlobalVars.UserConfiguration.DiscordPresence = (bool)discordRichPresenceBox.IsChecked; + GlobalVars.UserConfiguration.DiscordRichPresence = (bool)discordRichPresenceBox.IsChecked; } private void discordRichPresenceBox_Unchecked(object sender, RoutedEventArgs e) { if (!IsLoaded) return; - GlobalVars.UserConfiguration.DiscordPresence = (bool)discordRichPresenceBox.IsChecked; + GlobalVars.UserConfiguration.DiscordRichPresence = (bool)discordRichPresenceBox.IsChecked; } private void minimizeOnLaunchBox_Checked(object sender, RoutedEventArgs e) diff --git a/Novetus/NovetusLauncher/Forms/LauncherFormSettings.cs b/Novetus/NovetusLauncher/Forms/LauncherFormSettings.cs index e7adf44..876be73 100644 --- a/Novetus/NovetusLauncher/Forms/LauncherFormSettings.cs +++ b/Novetus/NovetusLauncher/Forms/LauncherFormSettings.cs @@ -20,15 +20,12 @@ namespace NovetusLauncher #region Form Events private void NovetusSettings_Load(object sender, EventArgs e) { - FileManagement.Config(GlobalPaths.ConfigDir + "\\" + GlobalPaths.ConfigName, true); ReadConfigValues(); CenterToScreen(); } private void NovetusSettings_Close(object sender, FormClosingEventArgs e) { - FileManagement.Config(GlobalPaths.ConfigDir + "\\" + GlobalPaths.ConfigName, true); - FormCollection fc = Application.OpenForms; foreach (Form frm in fc) diff --git a/Novetus/NovetusLauncher/Forms/SDK/NovetusSDK.cs b/Novetus/NovetusLauncher/Forms/SDK/NovetusSDK.cs index 58263f7..b7037c5 100644 --- a/Novetus/NovetusLauncher/Forms/SDK/NovetusSDK.cs +++ b/Novetus/NovetusLauncher/Forms/SDK/NovetusSDK.cs @@ -65,7 +65,6 @@ public partial class NovetusSDK : Form private void NovetusSDK_Close(object sender, CancelEventArgs e) { - FileManagement.Config(GlobalPaths.ConfigDir + "\\" + GlobalPaths.ConfigName, true); ClientManagement.ReadClientValues(); if (!IsLauncher && !GlobalVars.AppClosed) { diff --git a/Novetus/NovetusLauncher/Forms/ServerBrowser.cs b/Novetus/NovetusLauncher/Forms/ServerBrowser.cs index 5b5b295..8843f1f 100644 --- a/Novetus/NovetusLauncher/Forms/ServerBrowser.cs +++ b/Novetus/NovetusLauncher/Forms/ServerBrowser.cs @@ -97,14 +97,14 @@ namespace NovetusLauncher private async void ServerBrowser_Load(object sender, EventArgs e) { - MasterServerBox.Text = GlobalVars.UserConfiguration.ServerBrowserServerAddress; + MasterServerBox.Text = GlobalVars.UserConfiguration.ReadSetting("ServerBrowserServerAddress"); CenterToScreen(); await LoadServers(); } private void MasterServerBox_TextChanged(object sender, EventArgs e) { - GlobalVars.UserConfiguration.ServerBrowserServerAddress = MasterServerBox.Text; + GlobalVars.UserConfiguration.SaveSetting("ServerBrowserServerAddress", MasterServerBox.Text); } #endregion diff --git a/Novetus/NovetusLauncher/NovetusLauncherEntryPoint.cs b/Novetus/NovetusLauncher/NovetusLauncherEntryPoint.cs index d2be7b1..4094e28 100644 --- a/Novetus/NovetusLauncher/NovetusLauncherEntryPoint.cs +++ b/Novetus/NovetusLauncher/NovetusLauncherEntryPoint.cs @@ -49,7 +49,6 @@ namespace NovetusLauncher FileManagement.ReadInfoFile(GlobalPaths.ConfigDir + "\\" + GlobalPaths.InfoName, GlobalPaths.ConfigDir + "\\" + GlobalPaths.TermListFileName); - FileManagement.Config(GlobalPaths.ConfigDir + "\\" + GlobalPaths.ConfigName, false); GlobalVars.ColorsLoaded = FileManagement.InitColors(); bool isSDK = false; @@ -138,7 +137,7 @@ namespace NovetusLauncher { if (!sdk) { - switch (GlobalVars.UserConfiguration.LauncherStyle) + switch ((Settings.Style)GlobalVars.UserConfiguration.ReadSettingInt("LauncherStyle")) { case Settings.Style.Compact: LauncherFormCompact compact = new LauncherFormCompact(); diff --git a/Novetus/NovetusURI/Classes/LocalFuncs.cs b/Novetus/NovetusURI/Classes/LocalFuncs.cs index d50b1cb..1dff179 100644 --- a/Novetus/NovetusURI/Classes/LocalFuncs.cs +++ b/Novetus/NovetusURI/Classes/LocalFuncs.cs @@ -87,7 +87,7 @@ namespace NovetusURI string ip = SecurityFuncs.Decode(SplitArg[0]); string port = SecurityFuncs.Decode(SplitArg[1]); string client = SecurityFuncs.Decode(SplitArg[2]); - GlobalVars.UserConfiguration.SelectedClient = client; + GlobalVars.UserConfiguration.SaveSetting("SelectedClient", client); GlobalVars.CurrentServer.ServerIP = ip; GlobalVars.CurrentServer.ServerPort = Convert.ToInt32(port); ClientManagement.ReadClientValues(); diff --git a/Novetus/NovetusURI/Forms/LoaderForm.cs b/Novetus/NovetusURI/Forms/LoaderForm.cs index eaf536d..9021b5f 100644 --- a/Novetus/NovetusURI/Forms/LoaderForm.cs +++ b/Novetus/NovetusURI/Forms/LoaderForm.cs @@ -25,7 +25,7 @@ namespace NovetusURI { ClientManagement.UpdateStatus(label1, "Initializing..."); - if (GlobalVars.UserConfiguration.URIQuickConfigure) + if (GlobalVars.UserConfiguration.ReadSettingBool("URIQuickConfigure")) { ClientManagement.UpdateStatus(label1, "Loading Player Configuration Menu...."); QuickConfigure main = new QuickConfigure(); @@ -33,7 +33,6 @@ namespace NovetusURI } else { - FileManagement.Config(GlobalPaths.ConfigDir + "\\" + GlobalPaths.ConfigName, true); ClientManagement.ReadClientValues(); LocalVars.ReadyToLaunch = true; } @@ -62,7 +61,7 @@ namespace NovetusURI GlobalVars.GameOpened = ScriptType.None; } - if (GlobalVars.UserConfiguration.WebProxyEnabled) + if (GlobalVars.UserConfiguration.ReadSettingBool("WebProxyEnabled")) { GlobalVars.Proxy.Stop(); } @@ -81,7 +80,7 @@ namespace NovetusURI ClientManagement.UpdateStatus(label1, "Ready to launch."); Visible = true; CenterToScreen(); - if (GlobalVars.UserConfiguration.DiscordPresence) + if (GlobalVars.UserConfiguration.ReadSettingBool("DiscordRichPresence")) { ClientManagement.UpdateStatus(label1, "Starting Discord Rich Presence..."); DiscordRPC.StartDiscord(); diff --git a/Novetus/NovetusURI/Forms/QuickConfigure.cs b/Novetus/NovetusURI/Forms/QuickConfigure.cs index cbb8507..fcc8d2a 100644 --- a/Novetus/NovetusURI/Forms/QuickConfigure.cs +++ b/Novetus/NovetusURI/Forms/QuickConfigure.cs @@ -33,22 +33,21 @@ namespace NovetusURI void ReadConfigValues(string cfgpath) { - FileManagement.Config(cfgpath, false); - DontShowBox.Checked = !GlobalVars.UserConfiguration.URIQuickConfigure; - IDBox.Text = GlobalVars.UserConfiguration.UserID.ToString(); + DontShowBox.Checked = !GlobalVars.UserConfiguration.ReadSettingBool("URIQuickConfigure"); + IDBox.Text = GlobalVars.UserConfiguration.ReadSetting("UserID"); TripcodeLabel.Text = GlobalVars.PlayerTripcode.ToString(); - NameBox.Text = GlobalVars.UserConfiguration.PlayerName; + NameBox.Text = GlobalVars.UserConfiguration.ReadSetting("PlayerName"); } void GeneratePlayerID() { NovetusFuncs.GeneratePlayerID(); - IDBox.Text = GlobalVars.UserConfiguration.UserID.ToString(); + IDBox.Text = GlobalVars.UserConfiguration.ReadSetting("UserID"); } void TextBox1TextChanged(object sender, EventArgs e) { - GlobalVars.UserConfiguration.PlayerName = NameBox.Text; + GlobalVars.UserConfiguration.SaveSetting("PlayerName", NameBox.Text); } void TextBox2TextChanged(object sender, EventArgs e) @@ -58,16 +57,16 @@ namespace NovetusURI { if (IDBox.Text.Equals("")) { - GlobalVars.UserConfiguration.UserID = 0; + GlobalVars.UserConfiguration.SaveSettingInt("UserID", 0); } else { - GlobalVars.UserConfiguration.UserID = Convert.ToInt32(IDBox.Text); + GlobalVars.UserConfiguration.SaveSettingInt("UserID", Convert.ToInt32(IDBox.Text)); } } else { - GlobalVars.UserConfiguration.UserID = 0; + GlobalVars.UserConfiguration.SaveSettingInt("UserID", 0); } } @@ -83,12 +82,11 @@ namespace NovetusURI private void DontShowBox_CheckedChanged(object sender, EventArgs e) { - GlobalVars.UserConfiguration.URIQuickConfigure = !DontShowBox.Checked; + GlobalVars.UserConfiguration.SaveSettingBool("URIQuickConfigure", !DontShowBox.Checked); } void QuickConfigureClose(object sender, CancelEventArgs e) { - FileManagement.Config(GlobalPaths.ConfigDir + "\\" + GlobalPaths.ConfigName, true); ClientManagement.ReadClientValues(); LocalVars.ReadyToLaunch = true; } diff --git a/Novetus/NovetusURI/NovetusURI.cs b/Novetus/NovetusURI/NovetusURI.cs index b7d1b04..a74b145 100644 --- a/Novetus/NovetusURI/NovetusURI.cs +++ b/Novetus/NovetusURI/NovetusURI.cs @@ -33,7 +33,6 @@ namespace NovetusURI FileManagement.ReadInfoFile(GlobalPaths.ConfigDir + "\\" + GlobalPaths.InfoName, GlobalPaths.ConfigDir + "\\" + GlobalPaths.TermListFileName); - FileManagement.Config(GlobalPaths.ConfigDir + "\\" + GlobalPaths.ConfigName, false); GlobalVars.ColorsLoaded = FileManagement.InitColors(); if (args.Length == 0) {