public void loadScript(string scriptPath) { //Todo make sure this isn't blocking if it's a large cleanup. currentScript.close(); currentIndex = 0; currentScriptName = scriptPath; currentScript = new VisualNovelScript(scriptPath, novelDirectory); }
public void start() { Debug.Log("About to parse novel in " + novelDirectory); string[] subFolders = Directory.GetDirectories(novelDirectory); string[] topLevelFiles = Directory.GetFiles(novelDirectory); //Find out where our scripts live Debug.Log(cacheDirectory); if (Directory.Exists(cacheDirectory)) { try { Directory.Delete(cacheDirectory, true); } catch (System.Exception e) { Debug.Log("Couldn't delete stuff! IDK Why!"); } } try { Directory.CreateDirectory(cacheDirectory); } catch (System.Exception e) { Debug.Log("Couldn't create cache directory! You're gonna have a bad time!"); } if (!Directory.Exists(cacheDirectory + "/script")) { Directory.CreateDirectory(cacheDirectory + "/script"); } //Extract the main script file string scriptPath = novelDirectory + "/script/main.scr"; //By default assume it's in the normal script folder string scriptZipPath = novelDirectory + "/script.zip"; if (!File.Exists(scriptPath) && File.Exists(scriptZipPath)) { //Extract main.scr to start with using (ZipFile scriptZip = ZipFile.Read(scriptZipPath)) { try { Debug.Log("ATTEMPTING TO EXTRACT MAIN SCRIPT"); //scriptZip.ExtractSelectedEntries("name = main.scr", null, cacheDirectory); //scriptZip.ExtractAll(cacheDirectory); scriptPath = ArchiveUtil.extractFromZipFile(scriptZip, "/main.scr", cacheDirectory); //foreach (ZipEntry e in scriptZip.Entries) { // e.Extract(cacheDirectory); //} } catch (System.Exception e) { Debug.Log("Error extracting main.scr: " + e.Message); } } } //Read the main script file currentScript = new VisualNovelScript(scriptPath, novelDirectory); //Extract scripts //Load first script? }