From b9f1c64554beff989097e21dfab465666f44ec88 Mon Sep 17 00:00:00 2001 From: Bitl Date: Sat, 25 Sep 2021 15:01:42 -0700 Subject: [PATCH] fixed some annoying bugs --- .../Forms/LauncherForm/LauncherFormShared.cs | 30 ++++++++++++++++--- .../Stylish/LauncherFormStylish.cs | 6 ++-- .../LauncherFormStylishInterface.xaml.cs | 6 ++++ 3 files changed, 36 insertions(+), 6 deletions(-) diff --git a/Novetus/NovetusLauncher/Forms/LauncherForm/LauncherFormShared.cs b/Novetus/NovetusLauncher/Forms/LauncherForm/LauncherFormShared.cs index 73d485e..0ff1552 100644 --- a/Novetus/NovetusLauncher/Forms/LauncherForm/LauncherFormShared.cs +++ b/Novetus/NovetusLauncher/Forms/LauncherForm/LauncherFormShared.cs @@ -686,6 +686,9 @@ namespace NovetusLauncher public void SwitchStyles() { + if (LocalVars.launcherInitState) + return; + switch (StyleSelectorBox.SelectedIndex) { case 0: @@ -720,6 +723,8 @@ namespace NovetusLauncher { GlobalFuncs.Config(GlobalPaths.ConfigDir + "\\" + GlobalPaths.ConfigName, false); + ResetMapIfNecessary(); + CloseOnLaunchCheckbox.Checked = GlobalVars.UserConfiguration.CloseOnLaunch; PlayerIDTextBox.Text = GlobalVars.UserConfiguration.UserID.ToString(); PlayerTripcodeLabel.Text = GlobalVars.UserConfiguration.PlayerTripcode.ToString(); @@ -895,6 +900,8 @@ namespace NovetusLauncher public void RefreshMaps() { + ResetMapIfNecessary(); + Tree.Nodes.Clear(); _TreeCache.Nodes.Clear(); string mapdir = GlobalPaths.MapsDir; @@ -909,6 +916,11 @@ namespace NovetusLauncher TreeNodeHelper.ListDirectory(Tree, mapdir, fileexts); TreeNodeHelper.CopyNodes(Tree.Nodes, _TreeCache.Nodes); Tree.SelectedNode = TreeNodeHelper.SearchTreeView(GlobalVars.UserConfiguration.Map, Tree.Nodes); + if (FormStyle == Settings.Style.Stylish) + { + Tree.SelectedNode.BackColor = SystemColors.Highlight; + Tree.SelectedNode.ForeColor = SystemColors.HighlightText; + } Tree.Focus(); if (FormStyle != Settings.Style.Stylish) @@ -917,6 +929,16 @@ namespace NovetusLauncher } } + public void ResetMapIfNecessary() + { + if (!File.Exists(GlobalVars.UserConfiguration.MapPath)) + { + GlobalVars.UserConfiguration.Map = GlobalVars.ProgramInformation.DefaultMap; + GlobalVars.UserConfiguration.MapPath = GlobalPaths.MapsDir + @"\\" + GlobalVars.ProgramInformation.DefaultMap; + GlobalVars.UserConfiguration.MapPathSnip = GlobalPaths.MapsDirBase + @"\\" + GlobalVars.ProgramInformation.DefaultMap; + } + } + public void RestartLauncherAfterSetting(CheckBox box, string title, string subText) { RestartLauncherAfterSetting(box.Checked, title, subText); @@ -956,6 +978,9 @@ namespace NovetusLauncher private void LoadMapDesc() { + if (Tree.SelectedNode == null) + return; + if (File.Exists(GlobalPaths.RootPath + @"\\" + Tree.SelectedNode.FullPath.Replace(".rbxl", "").Replace(".rbxlx", "") + "_desc.txt")) { MapDescBox.Text = File.ReadAllText(GlobalPaths.RootPath + @"\\" + Tree.SelectedNode.FullPath.Replace(".rbxl", "").Replace(".rbxlx", "") + "_desc.txt"); @@ -1182,7 +1207,6 @@ namespace NovetusLauncher try { - GlobalFuncs.RenameFileWithInvalidChars(mapname); GlobalFuncs.FixedFileCopy(ofd.FileName, GlobalPaths.MapsDirCustom + @"\\" + mapname, true, true); } catch (Exception ex) @@ -1196,9 +1220,7 @@ namespace NovetusLauncher if (success) { RefreshMaps(); - Tree.SelectedNode = TreeNodeHelper.SearchTreeView(mapname, Tree.Nodes); - Tree.Focus(); - MessageBox.Show("The map '" + mapname + "' was successfully added to Novetus!" , "Novetus - Map Added", MessageBoxButtons.OK, MessageBoxIcon.Information); + MessageBox.Show("The map '" + mapname + "' was successfully added to Novetus! Look in the 'Custom' folder for it!" , "Novetus - Map Added", MessageBoxButtons.OK, MessageBoxIcon.Information); } } } diff --git a/Novetus/NovetusLauncher/Forms/LauncherForm/Stylish/LauncherFormStylish.cs b/Novetus/NovetusLauncher/Forms/LauncherForm/Stylish/LauncherFormStylish.cs index 64ebb64..1c69578 100644 --- a/Novetus/NovetusLauncher/Forms/LauncherForm/Stylish/LauncherFormStylish.cs +++ b/Novetus/NovetusLauncher/Forms/LauncherForm/Stylish/LauncherFormStylish.cs @@ -61,6 +61,8 @@ namespace NovetusLauncher launcherFormStylishInterface1.versionLabel.Content = Application.ProductVersion; launcherFormStylishInterface1.versionNovetusLabel.Content = GlobalVars.ProgramInformation.Version; + ReadConfigValues(true); + if (launcherFormStylishInterface1.playTab != null && launcherFormStylishInterface1.playTab.IsSelected) { if (launcherFormStylishInterface1.mapsBox.Nodes.Count == 0) @@ -72,8 +74,6 @@ namespace NovetusLauncher launcherFormStylishInterface1.ToggleServerOptions(); - ReadConfigValues(true); - LocalVars.launcherInitState = false; CenterToScreen(); } @@ -118,6 +118,8 @@ namespace NovetusLauncher { GlobalFuncs.Config(GlobalPaths.ConfigDir + "\\" + GlobalPaths.ConfigName, false); + launcherFormStylishInterface1.launcherForm.ResetMapIfNecessary(); + launcherFormStylishInterface1.minimizeOnLaunchBox.IsChecked = GlobalVars.UserConfiguration.CloseOnLaunch; launcherFormStylishInterface1.userIDBox.Text = GlobalVars.UserConfiguration.UserID.ToString(); launcherFormStylishInterface1.tripcodeLabel.Content = GlobalVars.UserConfiguration.PlayerTripcode.ToString(); diff --git a/Novetus/NovetusLauncher/Forms/LauncherForm/Stylish/LauncherFormStylishInterface.xaml.cs b/Novetus/NovetusLauncher/Forms/LauncherForm/Stylish/LauncherFormStylishInterface.xaml.cs index 27990f8..3343a69 100644 --- a/Novetus/NovetusLauncher/Forms/LauncherForm/Stylish/LauncherFormStylishInterface.xaml.cs +++ b/Novetus/NovetusLauncher/Forms/LauncherForm/Stylish/LauncherFormStylishInterface.xaml.cs @@ -99,6 +99,9 @@ namespace NovetusLauncher public void LoadMapDesc() { + if (mapsBox.SelectedNode == null) + return; + if (File.Exists(GlobalPaths.RootPath + @"\\" + mapsBox.SelectedNode.FullPath.Replace(".rbxl", "").Replace(".rbxlx", "") + "_desc.txt")) { mapsDescBox.Text = mapsBox.SelectedNode.Text + ": " + File.ReadAllText(GlobalPaths.RootPath + @"\\" + mapsBox.SelectedNode.FullPath.Replace(".rbxl", "").Replace(".rbxlx", "") + "_desc.txt"); @@ -461,6 +464,9 @@ namespace NovetusLauncher if (!IsLoaded) return; + if (LocalVars.launcherInitState) + return; + styleBox.Text = styleBox.SelectedItem.ToString(); switch (styleBox.SelectedIndex)