fixed some annoying bugs

This commit is contained in:
Bitl 2021-09-25 15:01:42 -07:00
parent f1324f3de9
commit b9f1c64554
3 changed files with 36 additions and 6 deletions

View File

@ -686,6 +686,9 @@ namespace NovetusLauncher
public void SwitchStyles() public void SwitchStyles()
{ {
if (LocalVars.launcherInitState)
return;
switch (StyleSelectorBox.SelectedIndex) switch (StyleSelectorBox.SelectedIndex)
{ {
case 0: case 0:
@ -720,6 +723,8 @@ namespace NovetusLauncher
{ {
GlobalFuncs.Config(GlobalPaths.ConfigDir + "\\" + GlobalPaths.ConfigName, false); GlobalFuncs.Config(GlobalPaths.ConfigDir + "\\" + GlobalPaths.ConfigName, false);
ResetMapIfNecessary();
CloseOnLaunchCheckbox.Checked = GlobalVars.UserConfiguration.CloseOnLaunch; CloseOnLaunchCheckbox.Checked = GlobalVars.UserConfiguration.CloseOnLaunch;
PlayerIDTextBox.Text = GlobalVars.UserConfiguration.UserID.ToString(); PlayerIDTextBox.Text = GlobalVars.UserConfiguration.UserID.ToString();
PlayerTripcodeLabel.Text = GlobalVars.UserConfiguration.PlayerTripcode.ToString(); PlayerTripcodeLabel.Text = GlobalVars.UserConfiguration.PlayerTripcode.ToString();
@ -895,6 +900,8 @@ namespace NovetusLauncher
public void RefreshMaps() public void RefreshMaps()
{ {
ResetMapIfNecessary();
Tree.Nodes.Clear(); Tree.Nodes.Clear();
_TreeCache.Nodes.Clear(); _TreeCache.Nodes.Clear();
string mapdir = GlobalPaths.MapsDir; string mapdir = GlobalPaths.MapsDir;
@ -909,6 +916,11 @@ namespace NovetusLauncher
TreeNodeHelper.ListDirectory(Tree, mapdir, fileexts); TreeNodeHelper.ListDirectory(Tree, mapdir, fileexts);
TreeNodeHelper.CopyNodes(Tree.Nodes, _TreeCache.Nodes); TreeNodeHelper.CopyNodes(Tree.Nodes, _TreeCache.Nodes);
Tree.SelectedNode = TreeNodeHelper.SearchTreeView(GlobalVars.UserConfiguration.Map, Tree.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(); Tree.Focus();
if (FormStyle != Settings.Style.Stylish) 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) public void RestartLauncherAfterSetting(CheckBox box, string title, string subText)
{ {
RestartLauncherAfterSetting(box.Checked, title, subText); RestartLauncherAfterSetting(box.Checked, title, subText);
@ -956,6 +978,9 @@ namespace NovetusLauncher
private void LoadMapDesc() private void LoadMapDesc()
{ {
if (Tree.SelectedNode == null)
return;
if (File.Exists(GlobalPaths.RootPath + @"\\" + Tree.SelectedNode.FullPath.Replace(".rbxl", "").Replace(".rbxlx", "") + "_desc.txt")) 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"); MapDescBox.Text = File.ReadAllText(GlobalPaths.RootPath + @"\\" + Tree.SelectedNode.FullPath.Replace(".rbxl", "").Replace(".rbxlx", "") + "_desc.txt");
@ -1182,7 +1207,6 @@ namespace NovetusLauncher
try try
{ {
GlobalFuncs.RenameFileWithInvalidChars(mapname);
GlobalFuncs.FixedFileCopy(ofd.FileName, GlobalPaths.MapsDirCustom + @"\\" + mapname, true, true); GlobalFuncs.FixedFileCopy(ofd.FileName, GlobalPaths.MapsDirCustom + @"\\" + mapname, true, true);
} }
catch (Exception ex) catch (Exception ex)
@ -1196,9 +1220,7 @@ namespace NovetusLauncher
if (success) if (success)
{ {
RefreshMaps(); RefreshMaps();
Tree.SelectedNode = TreeNodeHelper.SearchTreeView(mapname, Tree.Nodes); MessageBox.Show("The map '" + mapname + "' was successfully added to Novetus! Look in the 'Custom' folder for it!" , "Novetus - Map Added", MessageBoxButtons.OK, MessageBoxIcon.Information);
Tree.Focus();
MessageBox.Show("The map '" + mapname + "' was successfully added to Novetus!" , "Novetus - Map Added", MessageBoxButtons.OK, MessageBoxIcon.Information);
} }
} }
} }

View File

@ -61,6 +61,8 @@ namespace NovetusLauncher
launcherFormStylishInterface1.versionLabel.Content = Application.ProductVersion; launcherFormStylishInterface1.versionLabel.Content = Application.ProductVersion;
launcherFormStylishInterface1.versionNovetusLabel.Content = GlobalVars.ProgramInformation.Version; launcherFormStylishInterface1.versionNovetusLabel.Content = GlobalVars.ProgramInformation.Version;
ReadConfigValues(true);
if (launcherFormStylishInterface1.playTab != null && launcherFormStylishInterface1.playTab.IsSelected) if (launcherFormStylishInterface1.playTab != null && launcherFormStylishInterface1.playTab.IsSelected)
{ {
if (launcherFormStylishInterface1.mapsBox.Nodes.Count == 0) if (launcherFormStylishInterface1.mapsBox.Nodes.Count == 0)
@ -72,8 +74,6 @@ namespace NovetusLauncher
launcherFormStylishInterface1.ToggleServerOptions(); launcherFormStylishInterface1.ToggleServerOptions();
ReadConfigValues(true);
LocalVars.launcherInitState = false; LocalVars.launcherInitState = false;
CenterToScreen(); CenterToScreen();
} }
@ -118,6 +118,8 @@ namespace NovetusLauncher
{ {
GlobalFuncs.Config(GlobalPaths.ConfigDir + "\\" + GlobalPaths.ConfigName, false); GlobalFuncs.Config(GlobalPaths.ConfigDir + "\\" + GlobalPaths.ConfigName, false);
launcherFormStylishInterface1.launcherForm.ResetMapIfNecessary();
launcherFormStylishInterface1.minimizeOnLaunchBox.IsChecked = GlobalVars.UserConfiguration.CloseOnLaunch; launcherFormStylishInterface1.minimizeOnLaunchBox.IsChecked = GlobalVars.UserConfiguration.CloseOnLaunch;
launcherFormStylishInterface1.userIDBox.Text = GlobalVars.UserConfiguration.UserID.ToString(); launcherFormStylishInterface1.userIDBox.Text = GlobalVars.UserConfiguration.UserID.ToString();
launcherFormStylishInterface1.tripcodeLabel.Content = GlobalVars.UserConfiguration.PlayerTripcode.ToString(); launcherFormStylishInterface1.tripcodeLabel.Content = GlobalVars.UserConfiguration.PlayerTripcode.ToString();

View File

@ -99,6 +99,9 @@ namespace NovetusLauncher
public void LoadMapDesc() public void LoadMapDesc()
{ {
if (mapsBox.SelectedNode == null)
return;
if (File.Exists(GlobalPaths.RootPath + @"\\" + mapsBox.SelectedNode.FullPath.Replace(".rbxl", "").Replace(".rbxlx", "") + "_desc.txt")) 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"); 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) if (!IsLoaded)
return; return;
if (LocalVars.launcherInitState)
return;
styleBox.Text = styleBox.SelectedItem.ToString(); styleBox.Text = styleBox.SelectedItem.ToString();
switch (styleBox.SelectedIndex) switch (styleBox.SelectedIndex)