Пример #1
0
 /// <summary>
 /// Signals from MainForm that the form is ready to gather information
 /// </summary>
 public async Task Ready()
 {
     // goqsane: This is to prevent the settings being empty bug
     if (Settings.Values.UltimaPath == String.Empty)
     {
         Settings.Values.UltimaPath = RegistryChecker.GetUoPath();
         Settings.Save();
     }
     await DownloadServerInformationAsync();
 }
Пример #2
0
        public bool InstallUO(string path, int version)
        {
            bool result = RegistryChecker.InstallUoLoader(path, version);

            if (!result)
            {
                throw new Exception("Unable to install UO Loader. Check system file permissions and RegEdit permissions");
            }

            return(result);
        }
Пример #3
0
        private void SavePb_Click(object sender, EventArgs e)
        {
            _controller.Settings.Values.UltimaPath = PathLabel.Text;
            RegistryChecker.InstallUoLoader(PathLabel.Text, _controller.Settings.Values.Version);
            if (_controller.Settings.Save())
            {
                MessageBox.Show("Pomyślnie zapisano ustawienia UO Loader.", "Zapis pomyślny", MessageBoxButtons.OK,
                                MessageBoxIcon.Information);
                Close();
                return;
            }

            MessageBox.Show("Nie udało się zapisać ustawien UO Loader. Sprawdź software antywirusowy.", "Zapis nieudany", MessageBoxButtons.OK,
                            MessageBoxIcon.Error);
            Close();
        }
Пример #4
0
        public EntryPoint(AppController controller)
        {
            if (!RegistryChecker.IsUoLoaderInstalled())
            {
                var form = new InstallationForm(controller);
                form.ShowDialog();
                // Fix to a bug where Setting's UO path was incorrect
                controller.Settings.Values.UltimaPath = RegistryChecker.GetUoPath();
                controller.Settings.Save();
            }



            var mainForm = new MainForm(controller);

            mainForm.ShowDialog();
        }
Пример #5
0
        public static void BuildAndEmbedAssetBundles(FileInfo modDll, FileInfo weaverCoreDLL, MethodInfo OnComplete)
        {
            Data = new BundleBuildData
            {
                ModDLL             = modDll == null ? "" : modDll.FullName,
                ModName            = modDll == null ? "" : modDll.Name.Replace(".dll", ""),
                WeaverCoreOnly     = modDll == null,
                WeaverCoreDLL      = weaverCoreDLL.FullName,
                PreBuildInfo       = ScriptFinder.GetProjectScriptInfo(),
                ExcludedAssemblies = new List <ExcludedAssembly>(),
                OnComplete         = new SerializedMethod(OnComplete),
                BundlingSuccessful = false
            };
            /**/
            PrepareForAssetBundling(new List <string> {
                "WeaverCore.Editor"
            }, typeof(BundleTools).GetMethod(nameof(BeginBundleProcess), BindingFlags.Static | BindingFlags.NonPublic));
        }

        static bool IsFileLocked(FileInfo file)
        {
            try
            {
                using (FileStream stream = file.Open(FileMode.Open, FileAccess.Read, FileShare.None))
                {
                    stream.Close();
                }
            }
            catch (IOException)
            {
                //the file is unavailable because it is:
                //still being written to
                //or being processed by another thread
                //or does not exist (has already been processed)
                return(true);
            }

            //file is not locked
            return(false);
        }

        static void PrepareForAssetBundling(List <string> ExcludedAssemblies, MethodInfo whenReady)
        {
            //AssetDatabase.DisallowAutoRefresh();
            Debug.Log("Preparing Assets for Bundling");
            //UnboundCoroutine.Start(Delay());
            //IEnumerator Delay()
            //{

            /*yield return new WaitForSeconds(0.5f);
             * foreach (var registry in RegistryChecker.LoadAllRegistries())
             * {
             *      registry.ReplaceAssemblyName("Assembly-CSharp", Data.ModName);
             *      registry.ApplyChanges();
             * }*/
            //Debug.Log("A_Editor File Locked = " + IsFileLocked(new FileInfo("Library\\ScriptAssemblies\\WeaverCore.Editor.dll")));

            /*var buildCache = new DirectoryInfo("Library\\BuildCache");
             * if (buildCache.Exists)
             * {
             *      buildCache.Delete(true);
             * }*/
            //yield return new WaitForSeconds(0.5f);
            //Debug.Log("B_Editor File Locked = " + IsFileLocked(new FileInfo("Library\\ScriptAssemblies\\WeaverCore.Editor.dll")));
            //yield return new WaitUntil(() => !EditorApplication.isCompiling);
            //AssetDatabase.Refresh(ImportAssetOptions.ForceSynchronousImport);
            //yield return new WaitForSeconds(0.5f);
            //Debug.Log("C_Editor File Locked = " + IsFileLocked(new FileInfo("Library\\ScriptAssemblies\\WeaverCore.Editor.dll")));
            //yield return new WaitUntil(() => !EditorApplication.isCompiling);
#if REWRITE_REGISTRIES
            foreach (var registry in RegistryChecker.LoadAllRegistries())
            {
                registry.ReplaceAssemblyName("Assembly-CSharp", Data.ModName);
                registry.ApplyChanges();
            }
#endif
            Data.Registries = new List <RegistryInfo>();
            var registryIDs = AssetDatabase.FindAssets($"t:{nameof(Registry)}");
            foreach (var id in registryIDs)
            {
                var path     = AssetDatabase.GUIDToAssetPath(id);
                var registry = AssetDatabase.LoadAssetAtPath <Registry>(path);
                Data.Registries.Add(new RegistryInfo
                {
                    AssemblyName    = registry.ModAssemblyName,
                    AssetBundleName = GetAssetBundleName(registry),
                    ModTypeName     = registry.ModName,
                    RegistryName    = registry.RegistryName,
                    Path            = path
                });
            }
            //yield return new WaitForSeconds(0.5f);
            //Debug.Log("D_Editor File Locked = " + IsFileLocked(new FileInfo("Library\\ScriptAssemblies\\WeaverCore.Editor.dll")));
            //yield return new WaitUntil(() => !EditorApplication.isCompiling);
            bool assetsChanged = false;
            try
            {
                AssetDatabase.StartAssetEditing();
                foreach (var asm in Data.PreBuildInfo.Where(i => ExcludedAssemblies.Contains(i.AssemblyName)))
                {
                    if (asm.Definition.includePlatforms.Count == 1 && asm.Definition.includePlatforms[0] == "Editor")
                    {
                        continue;
                    }
                    Data.ExcludedAssemblies.Add(new ExcludedAssembly()
                    {
                        AssemblyName = asm.AssemblyName,
                        OriginalExcludedPlatforms = asm.Definition.excludePlatforms,
                        OriginalIncludedPlatforms = asm.Definition.includePlatforms
                    });
                    asm.Definition.excludePlatforms = new List <string>();
                    asm.Definition.includePlatforms = new List <string>
                    {
                        "Editor"
                    };
                    //Debug.Log("Asm Definition Path = " + asm.AssemblyDefinitionPath);
                    //Debug.Log("Importing Asset = " + asm.AssemblyDefinitionPath);
                    asm.Save();
                    AssetDatabase.ImportAsset(asm.AssemblyDefinitionPath, ImportAssetOptions.ForceUpdate);
                    assetsChanged = true;
                }
                if (assetsChanged)
                {
                    Data.NextMethod = new SerializedMethod(whenReady);
                }
                else
                {
                    Data.NextMethod = default;
                }
                PersistentData.StoreData(Data);
                PersistentData.SaveData();

                if (!assetsChanged && whenReady != null)
                {
                    whenReady.Invoke(null, null);
                }
            }
            catch (Exception e)
            {
                Debug.LogError("Exception occured" + e);
            }
            finally
            {
                AssetDatabase.StopAssetEditing();
                //if (assetsChanged)
                //{
                //AssetDatabase.Refresh(ImportAssetOptions.ForceUpdate);
                //}
            }
            //}
        }
Пример #6
0
        static void DoneWithAssetBundling(MethodInfo whenFinished)
        {
            //Debug.Log("Done with Asset Bundling");
            //UnboundCoroutine.Start(Routine());
            //IEnumerator Routine()
            //{

            /*yield return new WaitForSeconds(0.5f);
             * foreach (var registry in RegistryChecker.LoadAllRegistries())
             * {
             *      registry.ReplaceAssemblyName(Data.ModName, "Assembly-CSharp");
             *      registry.ApplyChanges();
             * }*/
            //Debug.Log("G_Editor File Locked = " + IsFileLocked(new FileInfo("Library\\ScriptAssemblies\\WeaverCore.Editor.dll")));
            //yield return new WaitForSeconds(0.5f);
            //yield return new WaitUntil(() => !EditorApplication.isCompiling);
            //Debug.Log("H_Editor File Locked = " + IsFileLocked(new FileInfo("Library\\ScriptAssemblies\\WeaverCore.Editor.dll")));
            //AssetDatabase.Refresh(ImportAssetOptions.ForceUpdate | ImportAssetOptions.ForceSynchronousImport);
            //Debug.Log("I_Editor File Locked = " + IsFileLocked(new FileInfo("Library\\ScriptAssemblies\\WeaverCore.Editor.dll")));
            //yield return new WaitForSeconds(0.5f);
            //Debug.Log("J_Editor File Locked = " + IsFileLocked(new FileInfo("Library\\ScriptAssemblies\\WeaverCore.Editor.dll")));
            //yield return new WaitUntil(() => !EditorApplication.isCompiling);
#if REWRITE_REGISTRIES
            foreach (var registry in RegistryChecker.LoadAllRegistries())
            {
                registry.ReplaceAssemblyName(Data.ModName, "Assembly-CSharp");
                registry.ApplyChanges();
            }
#endif
            //yield return new WaitForSeconds(0.5f);
            //Debug.Log("K_Editor File Locked = " + IsFileLocked(new FileInfo("Library\\ScriptAssemblies\\WeaverCore.Editor.dll")));
            //yield return new WaitUntil(() => !EditorApplication.isCompiling);
            bool assetsChanged = false;
            try
            {
                AssetDatabase.StartAssetEditing();
                if (Data.ExcludedAssemblies != null)
                {
                    foreach (var exclusion in Data.ExcludedAssemblies)
                    {
                        var asmDef = Data.PreBuildInfo.FirstOrDefault(a => a.AssemblyName == exclusion.AssemblyName);
                        if (asmDef != null)
                        {
                            asmDef.Definition.includePlatforms = exclusion.OriginalIncludedPlatforms;
                            asmDef.Definition.excludePlatforms = exclusion.OriginalExcludedPlatforms;
                            asmDef.Save();
                            assetsChanged = true;
                            AssetDatabase.ImportAsset(asmDef.AssemblyDefinitionPath, ImportAssetOptions.ForceUpdate);
                        }
                    }
                }
                if (assetsChanged)
                {
                    Data.NextMethod = new SerializedMethod(whenFinished);
                }
                else
                {
                    Data.NextMethod = default;
                }
                PersistentData.StoreData(Data);
                PersistentData.SaveData();

                if (!assetsChanged && whenFinished != null)
                {
                    whenFinished.Invoke(null, null);
                }
            }
            finally
            {
                //if (assetsChanged)
                //{
                //	AssetDatabase.Refresh(ImportAssetOptions.ForceUpdate);
                //}
                //Debug.Log("L_Editor File Locked = " + IsFileLocked(new FileInfo("Library\\ScriptAssemblies\\WeaverCore.Editor.dll")));
                //AssetDatabase.AllowAutoRefresh();
                AssetDatabase.StopAssetEditing();
            }
            //}
        }
Пример #7
0
 void OnEnable()
 {
     //Debug.Log("Checker Enabled");
     checker = new RegistryChecker(serializedObject);
     checker.Check();
 }