diff --git a/Novetus/NovetusCore/Classes/Downloader.cs b/Novetus/NovetusCore/Classes/Downloader.cs index 32919bf..2627e4c 100644 --- a/Novetus/NovetusCore/Classes/Downloader.cs +++ b/Novetus/NovetusCore/Classes/Downloader.cs @@ -110,7 +110,7 @@ class Downloader { //wait a few seconds for the download to finish //Thread.Sleep(2000); - if (/*File.Exists(name)*/ read > 0) + if (File.Exists(name) && read > 0) { downloadOutcome = "File " + Path.GetFileName(name) + " downloaded! " + GlobalFuncs.SizeSuffix(Convert.ToInt64(read), 2) + " written (" + read + " bytes)! " + additionalText; } diff --git a/Novetus/NovetusCore/Classes/ROBLOXHelpers.cs b/Novetus/NovetusCore/Classes/ROBLOXHelpers.cs index 21cc354..abb2872 100644 --- a/Novetus/NovetusCore/Classes/ROBLOXHelpers.cs +++ b/Novetus/NovetusCore/Classes/ROBLOXHelpers.cs @@ -27,9 +27,8 @@ public enum RobloxFileType TShirt, Shirt, Pants, - HeadNoCustomMesh, - //for downloading script assets - //Script + Script, + HeadNoCustomMesh } #endregion diff --git a/Novetus/NovetusCore/Classes/RobloxXML.cs b/Novetus/NovetusCore/Classes/RobloxXML.cs index 85c1a4e..0097665 100644 --- a/Novetus/NovetusCore/Classes/RobloxXML.cs +++ b/Novetus/NovetusCore/Classes/RobloxXML.cs @@ -1,5 +1,6 @@ #region Usings using System; +using System.IO; using System.Linq; using System.Text.RegularExpressions; using System.Windows.Forms; @@ -135,7 +136,7 @@ public static class RobloxXML return ""; } - private static void DownloadFilesFromNode(string url, string path, string fileext, string id) + public static void DownloadFilesFromNode(string url, string path, string fileext, string id) { if (!string.IsNullOrWhiteSpace(id)) { @@ -144,6 +145,10 @@ public static class RobloxXML try { download.InitDownload(path, fileext, "", true); + if (download.getDownloadOutcome().Contains("Error")) + { + throw new IOException(download.getDownloadOutcome()); + } } #if URI || LAUNCHER || CMD || BASICLAUNCHER catch (Exception ex) @@ -396,90 +401,6 @@ public static class RobloxXML return ""; } - //TODO: actually download the script assets instead of fixing the scripts lol. fixing the scripts won't work anyways because we don't support https natively. - /* - public static void DownloadScriptFromNodes(string filepath, string itemClassValue) - { - string oldfile = File.ReadAllText(filepath); - string fixedfile = RemoveInvalidXmlChars(ReplaceHexadecimalSymbols(oldfile)); - XDocument doc = XDocument.Parse(fixedfile); - - try - { - var v = from nodes in doc.Descendants("Item") - where nodes.Attribute("class").Value == itemClassValue - select nodes; - - foreach (var item in v) - { - var v2 = from nodes in item.Descendants("Properties") - select nodes; - - foreach (var item2 in v2) - { - var v3 = from nodes in doc.Descendants("ProtectedString") - where nodes.Attribute("name").Value == "Source" - select nodes; - - foreach (var item3 in v3) - { - string newurl = "assetdelivery.roblox.com/v1/asset/?id="; - item3.Value.Replace("http://", "https://") - .Replace("?version=1&id=", "?id=") - .Replace("www.roblox.com/asset/?id=", newurl) - .Replace("www.roblox.com/asset?id=", newurl) - .Replace("assetgame.roblox.com/asset/?id=", newurl) - .Replace("assetgame.roblox.com/asset?id=", newurl) - .Replace("roblox.com/asset/?id=", newurl) - .Replace("roblox.com/asset?id=", newurl); - } - } - } - } - catch (Exception ex) - { - GlobalFuncs.LogExceptions(ex); - MessageBox.Show("The download has experienced an error: " + ex.Message, "Novetus Asset SDK - Error", MessageBoxButtons.OK, MessageBoxIcon.Error); - } - finally - { - doc.Save(filepath); - } - } - - public static void DownloadFromScript(string filepath) - { - string[] file = File.ReadAllLines(filepath); - - try - { - foreach (var line in file) - { - if (line.Contains("www.roblox.com/asset/?id=") || line.Contains("assetgame.roblox.com/asset/?id=")) - { - string newurl = "assetdelivery.roblox.com/v1/asset/?id="; - line.Replace("http://", "https://") - .Replace("?version=1&id=", "?id=") - .Replace("www.roblox.com/asset/?id=", newurl) - .Replace("www.roblox.com/asset?id=", newurl) - .Replace("assetgame.roblox.com/asset/?id=", newurl) - .Replace("assetgame.roblox.com/asset?id=", newurl) - .Replace("roblox.com/asset/?id=", newurl) - .Replace("roblox.com/asset?id=", newurl); - } - } - } - catch (Exception ex) - { - GlobalFuncs.LogExceptions(ex); - MessageBox.Show("The download has experienced an error: " + ex.Message, "Novetus Asset SDK - Error", MessageBoxButtons.OK, MessageBoxIcon.Error); - } - finally - { - File.WriteAllLines(filepath, file); - } - }*/ - public static string RemoveInvalidXmlChars(string content) { return new string(content.Where(ch => XmlConvert.IsXmlChar(ch)).ToArray()); diff --git a/Novetus/NovetusCore/StorageAndFunctions/GlobalFuncs.cs b/Novetus/NovetusCore/StorageAndFunctions/GlobalFuncs.cs index dc5bef0..051fb3f 100644 --- a/Novetus/NovetusCore/StorageAndFunctions/GlobalFuncs.cs +++ b/Novetus/NovetusCore/StorageAndFunctions/GlobalFuncs.cs @@ -1190,6 +1190,10 @@ public class GlobalFuncs string id = item.After(peram); fullname = id + ".png"; } + else + { + return item; + } Downloader download = new Downloader(item, fullname, "", GlobalPaths.AssetCacheDirTextures); @@ -1224,6 +1228,12 @@ public class GlobalFuncs if (item.Contains("http://") || item.Contains("https://")) { + string peram = "id="; + if (!item.Contains(peram)) + { + return item; + } + Downloader download = new Downloader(item, name + "Temp.rbxm", "", GlobalPaths.AssetCacheDirFonts); try @@ -2468,6 +2478,11 @@ public class GlobalFuncs Directory.CreateDirectory(GlobalPaths.AssetCacheDirSounds); } + if (!Directory.Exists(GlobalPaths.AssetCacheDirTextures)) + { + Directory.CreateDirectory(GlobalPaths.AssetCacheDirTextures); + } + if (!Directory.Exists(GlobalPaths.AssetCacheDirTexturesGUI)) { Directory.CreateDirectory(GlobalPaths.AssetCacheDirTexturesGUI); @@ -2477,12 +2492,11 @@ public class GlobalFuncs { Directory.CreateDirectory(GlobalPaths.AssetCacheDirScripts); } - - /* - if (!Directory.Exists(GlobalPaths.AssetCacheDirScriptAssets)) + + if (!Directory.Exists(GlobalPaths.AssetCacheDirAssets)) { - Directory.CreateDirectory(GlobalPaths.AssetCacheDirScriptAssets); - }*/ + Directory.CreateDirectory(GlobalPaths.AssetCacheDirAssets); + } } // Credit to Carrot for the original code. Rewote it to be smaller. diff --git a/Novetus/NovetusCore/StorageAndFunctions/GlobalPaths.cs b/Novetus/NovetusCore/StorageAndFunctions/GlobalPaths.cs index 1f21498..7e783f6 100644 --- a/Novetus/NovetusCore/StorageAndFunctions/GlobalPaths.cs +++ b/Novetus/NovetusCore/StorageAndFunctions/GlobalPaths.cs @@ -69,7 +69,7 @@ public class GlobalPaths public static string AssetCacheDirTextures = AssetCacheDir + DirTextures; public static string AssetCacheDirTexturesGUI = AssetCacheDirTextures + "\\gui"; public static string AssetCacheDirScripts = AssetCacheDir + DirScripts; - //public static string AssetCacheDirScriptAssets = AssetCacheDir + "\\scriptassets"; + public static string AssetCacheDirAssets = AssetCacheDir + "\\assets"; public static string AssetCacheGameDir = SharedDataGameDir + "assetcache/"; public static string AssetCacheFontsGameDir = AssetCacheGameDir + FontsGameDir; @@ -78,7 +78,7 @@ public class GlobalPaths public static string AssetCacheTexturesGameDir = AssetCacheGameDir + TexturesGameDir; public static string AssetCacheTexturesGUIGameDir = AssetCacheTexturesGameDir + "gui/"; public static string AssetCacheScriptsGameDir = AssetCacheGameDir + ScriptsGameDir; - //public static string AssetCacheScriptAssetsGameDir = AssetCacheGameDir + "scriptassets/"; + public static string AssetCacheAssetsGameDir = AssetCacheGameDir + "assets/"; #endregion #region Item Dirs diff --git a/Novetus/NovetusLauncher/Forms/LauncherForm/LauncherFormShared.cs b/Novetus/NovetusLauncher/Forms/LauncherForm/LauncherFormShared.cs index 2a9db34..cd62838 100644 --- a/Novetus/NovetusLauncher/Forms/LauncherForm/LauncherFormShared.cs +++ b/Novetus/NovetusLauncher/Forms/LauncherForm/LauncherFormShared.cs @@ -1053,6 +1053,7 @@ namespace NovetusLauncher if (Directory.Exists(GlobalPaths.AssetCacheDir)) { Directory.Delete(GlobalPaths.AssetCacheDir, true); + GlobalFuncs.CreateAssetCacheDirectories(); GlobalFuncs.ConsolePrint("Asset cache cleared!", 3, ConsoleBox); MessageBox.Show("Asset cache cleared!", "Novetus - Asset Cache Cleared", MessageBoxButtons.OK, MessageBoxIcon.Information); } diff --git a/Novetus/NovetusLauncher/Forms/LauncherForm/Stylish/LauncherFormStylishInterface.xaml b/Novetus/NovetusLauncher/Forms/LauncherForm/Stylish/LauncherFormStylishInterface.xaml index 413baf5..ca6846e 100644 --- a/Novetus/NovetusLauncher/Forms/LauncherForm/Stylish/LauncherFormStylishInterface.xaml +++ b/Novetus/NovetusLauncher/Forms/LauncherForm/Stylish/LauncherFormStylishInterface.xaml @@ -853,7 +853,7 @@