public static void UpdateModule(ModuleHeader module)
 {
     module.is_being_installed_or_removed = true;
     Helper.SaveValueToFile("update_module_url", module.url, ".thry_after_compile_data");
     Helper.SaveValueToFile("update_module_name", module.available_module.name, ".thry_after_compile_data");
     RemoveModule(module);
 }
 public static void UpdateModule(ModuleHeader module)
 {
     module.is_being_installed_or_removed = true;
     FileHelper.SaveValueToFile("update_module_url", module.url, PATH.AFTER_COMPILE_DATA);
     FileHelper.SaveValueToFile("update_module_name", module.available_module.name, PATH.AFTER_COMPILE_DATA);
     RemoveModule(module);
 }
 private static void LoadModules()
 {
     modules_are_being_loaded = true;
     WebHelper.DownloadStringASync(URL.PUBLIC_MODULES_COLLECTION, delegate(string s) {
         modules = new List <ModuleHeader>();
         List <string> module_urls = Parser.ParseToObject <List <string> >(s);
         foreach (string url in module_urls)
         {
             WebHelper.DownloadStringASync(url, delegate(string data)
             {
                 ModuleHeader new_module     = new ModuleHeader();
                 new_module.url              = url;
                 new_module.available_module = Parser.ParseToObject <ModuleInfo>(data);
                 InitInstalledModule(new_module);
                 if (new_module.available_module.requirement != null)
                 {
                     new_module.available_requirement_fullfilled = new_module.available_module.requirement.Test();
                 }
                 modules.Add(new_module);
                 //Debug.Log(Parser.ObjectToString(new_module));
                 UnityHelper.RepaintEditorWindow(typeof(Settings));
             });
         }
     });
 }
 public static void RemoveModule(ModuleHeader module)
 {
     module.is_being_installed_or_removed = true;
     foreach (Action f in pre_module_remove_functions)
     {
         f.Invoke();
     }
     TrashHandler.MoveDirectoryToTrash(module.path);
     AssetDatabase.Refresh();
 }
 public static void InstallRemoveModule(ModuleHeader module, bool install)
 {
     if (install && !Helper.ClassExists(module.available_module.classname))
     {
         InstallModule(module);
     }
     else if (!install && Helper.ClassExists(module.available_module.classname))
     {
         RemoveModule(module);
     }
 }
 private static void InitInstalledModule(ModuleHeader m)
 {
     if (Helper.ClassExists(m.available_module.classname))
     {
         string path = GetModuleDirectoryPath(m) + "/module.json";
         if (File.Exists(path))
         {
             m.installed_module = Parser.ParseToObject <ModuleInfo>(Helper.ReadFileIntoString(path));
         }
     }
 }
 private static string GetModuleDirectoryPath(ModuleHeader module)
 {
     string[] guids = AssetDatabase.FindAssets(module.available_module.settings_file_name.RemoveFileExtension());
     foreach (string g in guids)
     {
         string path = AssetDatabase.GUIDToAssetPath(g);
         if (path.EndsWith(module.available_module.settings_file_name.RemoveFileExtension() + ".cs"))
         {
             path = path.GetDirectoryPath().RemoveOneDirectory();
             if (Directory.Exists(path))
             {
                 return(path);
             }
         }
     }
     return("");
 }
Exemplo n.º 8
0
        public static void RemoveModule(ModuleHeader module)
        {
            module.is_being_installed_or_removed = true;
            foreach (Action f in pre_module_remove_functions)
            {
                f.Invoke();
            }
            string path = GetModuleDirectoryPath(module);
            int    i    = 0;

            if (!Directory.Exists(PATH.DELETING_DIR))
            {
                Directory.CreateDirectory(PATH.DELETING_DIR);
            }
            string newpath = PATH.DELETING_DIR + "/" + module.available_module.name + i;

            while (Directory.Exists(newpath))
            {
                newpath = PATH.DELETING_DIR + "/" + module.available_module.name + (++i);
            }
            Directory.Move(path, newpath);
            AssetDatabase.Refresh();
        }
 public static void InstallModule(ModuleHeader module)
 {
     module.is_being_installed_or_removed = true;
     InstallModule(module.url, module.available_module.name);
 }