fix certain bugs
This commit is contained in:
parent
28070e1aaa
commit
7df557baa8
|
|
@ -211,8 +211,9 @@ public class GlobalFuncs
|
|||
GlobalVars.UserConfiguration.DiscordPresence = Convert.ToBoolean(discord);
|
||||
GlobalVars.UserConfiguration.MapPathSnip = mapsnip;
|
||||
|
||||
string oldMapath = Path.GetDirectoryName(GlobalVars.UserConfiguration.MapPath);
|
||||
//update the map path if the file doesn't exist and write to config.
|
||||
if (File.Exists(mappath))
|
||||
if (oldMapath.Equals(GlobalPaths.MapsDir.Replace(@"\\", @"\")) && File.Exists(mappath))
|
||||
{
|
||||
GlobalVars.UserConfiguration.MapPath = mappath;
|
||||
}
|
||||
|
|
@ -1760,28 +1761,50 @@ public class GlobalFuncs
|
|||
SizeSuffixes[mag]);
|
||||
}
|
||||
|
||||
//https://www.meziantou.net/getting-the-date-of-build-of-a-dotnet-assembly-at-runtime.htm
|
||||
public static DateTime GetLinkerTimestampUtc(Assembly assembly)
|
||||
//https://stackoverflow.com/questions/11927116/getting-files-recursively-skip-files-directories-that-cannot-be-read
|
||||
public static string[] FindAllFiles(string rootDir)
|
||||
{
|
||||
var location = assembly.Location;
|
||||
return GetLinkerTimestampUtc(location);
|
||||
}
|
||||
var pathsToSearch = new Queue<string>();
|
||||
var foundFiles = new List<string>();
|
||||
|
||||
public static DateTime GetLinkerTimestampUtc(string filePath)
|
||||
{
|
||||
const int peHeaderOffset = 60;
|
||||
const int linkerTimestampOffset = 8;
|
||||
var bytes = new byte[2048];
|
||||
pathsToSearch.Enqueue(rootDir);
|
||||
|
||||
using (var file = new FileStream(filePath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
|
||||
while (pathsToSearch.Count > 0)
|
||||
{
|
||||
file.Read(bytes, 0, bytes.Length);
|
||||
var dir = pathsToSearch.Dequeue();
|
||||
|
||||
try
|
||||
{
|
||||
var files = Directory.GetFiles(dir);
|
||||
foreach (var file in Directory.GetFiles(dir))
|
||||
{
|
||||
foundFiles.Add(file);
|
||||
}
|
||||
|
||||
foreach (var subDir in Directory.GetDirectories(dir))
|
||||
{
|
||||
pathsToSearch.Enqueue(subDir);
|
||||
}
|
||||
|
||||
}
|
||||
catch (Exception /* TODO: catch correct exception */)
|
||||
{
|
||||
// Swallow. Gulp!
|
||||
}
|
||||
}
|
||||
|
||||
var headerPos = BitConverter.ToInt32(bytes, peHeaderOffset);
|
||||
var secondsSince1970 = BitConverter.ToInt32(bytes, headerPos + linkerTimestampOffset);
|
||||
var dt = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
|
||||
return dt.AddSeconds(secondsSince1970);
|
||||
return foundFiles.ToArray();
|
||||
}
|
||||
|
||||
//https://stackoverflow.com/questions/66667263/i-want-to-remove-special-characters-from-file-name-without-affecting-extension-i
|
||||
//https://stackoverflow.com/questions/3218910/rename-a-file-in-c-sharp
|
||||
public static void RenameFileWithInvalidChars(string path)
|
||||
{
|
||||
string pathWithoutFilename = Path.GetDirectoryName(path);
|
||||
string fileName = Path.GetFileName(path);
|
||||
fileName = Regex.Replace(fileName, @"[^\w-.'_! ]", "");
|
||||
|
||||
File.Move(path, pathWithoutFilename + "\\" + fileName);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
|
|
|||
|
|
@ -322,12 +322,7 @@ namespace NovetusLauncher
|
|||
PortBox.Items.Clear();
|
||||
break;
|
||||
case TabPage pg4 when pg4 == Tabs.TabPages[TabPageMaps]:
|
||||
string mapdir = GlobalPaths.MapsDir;
|
||||
string[] fileexts = new string[] { ".rbxl", ".rbxlx" };
|
||||
TreeNodeHelper.ListDirectory(Tree, mapdir, fileexts);
|
||||
TreeNodeHelper.CopyNodes(Tree.Nodes, _TreeCache.Nodes);
|
||||
Tree.SelectedNode = TreeNodeHelper.SearchTreeView(GlobalVars.UserConfiguration.Map, Tree.Nodes);
|
||||
Tree.Focus();
|
||||
RefreshMaps();
|
||||
ServerInfo.Text = "";
|
||||
ClientBox.Items.Clear();
|
||||
ServerBox.Items.Clear();
|
||||
|
|
@ -903,6 +898,13 @@ namespace NovetusLauncher
|
|||
Tree.Nodes.Clear();
|
||||
_TreeCache.Nodes.Clear();
|
||||
string mapdir = GlobalPaths.MapsDir;
|
||||
string[] filePaths = GlobalFuncs.FindAllFiles(GlobalPaths.MapsDir);
|
||||
|
||||
foreach (string path in filePaths)
|
||||
{
|
||||
GlobalFuncs.RenameFileWithInvalidChars(path);
|
||||
}
|
||||
|
||||
string[] fileexts = new string[] { ".rbxl", ".rbxlx" };
|
||||
TreeNodeHelper.ListDirectory(Tree, mapdir, fileexts);
|
||||
TreeNodeHelper.CopyNodes(Tree.Nodes, _TreeCache.Nodes);
|
||||
|
|
@ -1181,6 +1183,7 @@ namespace NovetusLauncher
|
|||
|
||||
try
|
||||
{
|
||||
GlobalFuncs.RenameFileWithInvalidChars(mapname);
|
||||
GlobalFuncs.FixedFileCopy(ofd.FileName, GlobalPaths.MapsDirCustom + @"\\" + mapname, true, true);
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
|
|
|||
|
|
@ -44,6 +44,7 @@ namespace NovetusLauncher
|
|||
case Settings.UIOptions.Style.Compact:
|
||||
Application.Run(new LauncherFormCompact());
|
||||
break;
|
||||
case Settings.UIOptions.Style.Extended:
|
||||
default:
|
||||
Application.Run(new LauncherFormExtended());
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -71,15 +71,14 @@ namespace NovetusURI
|
|||
{
|
||||
switch(GlobalVars.UserConfiguration.LauncherStyle)
|
||||
{
|
||||
case Settings.UIOptions.Style.Extended:
|
||||
CharacterCustomizationExtended ccustom = new CharacterCustomizationExtended();
|
||||
ccustom.Show();
|
||||
break;
|
||||
case Settings.UIOptions.Style.Compact:
|
||||
CharacterCustomizationCompact ccustom2 = new CharacterCustomizationCompact();
|
||||
ccustom2.Show();
|
||||
break;
|
||||
case Settings.UIOptions.Style.Extended:
|
||||
default:
|
||||
CharacterCustomizationExtended ccustom = new CharacterCustomizationExtended();
|
||||
ccustom.Show();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,6 +19,8 @@
|
|||
- Item Creation SDK: If a character customization window is open, it will now close the window and open a new one to update the contents.
|
||||
- Item Creation SDK: Added the optional ability to replace existing item icons.
|
||||
- Added the XML Content Editor: a Excel-like editor that allows you to edit and add content providers and part colors.
|
||||
- The Novetus Launcher will now remove any invalid characters from a map's file name.
|
||||
- Fixed an issue with the Launcher where the internal map file path wouldn't automatically change if the directory changed. Portable installations should work properly now.
|
||||
Added the following T-Shirts:
|
||||
Blue Ring of Fire
|
||||
Ring of Fire
|
||||
|
|
|
|||
Loading…
Reference in New Issue