public void OnGUI() { GUI.DrawTexture(new Rect(0f, 0f, (float)Screen.width, (float)Screen.height), ResourceManager.LoadTexture("DeckBuilder/bg")); new ScrollsFrame(new Rect((float)Screen.width / 15.0f, (float)Screen.height / 5.0f, (float)Screen.width / 15.0f * 8.0f, (float)Screen.height / 6.0f * 4.0f)).AddNinePatch(ScrollsFrame.Border.LIGHT_CURVED, NinePatch.Patches.CENTER).Draw(); new ScrollsFrame(new Rect((float)Screen.width / 15.0f * 9.5f, (float)Screen.height / 5.0f, (float)Screen.width / 15.0f * 4.5f, (float)Screen.height / 6.0f * 4.0f)).AddNinePatch(ScrollsFrame.Border.LIGHT_CURVED, NinePatch.Patches.CENTER).Draw(); Color textColor = GUI.skin.label.normal.textColor; GUI.skin.label.normal.textColor = Color.white; GUI.skin.label.fontSize = (int)(((float)(0x1c * Screen.height)) / 1080f); GUI.Label(new Rect((float)Screen.width / 15.0f + (float)Screen.width / 35.0f + (float)Screen.width / 4.5f / 2.0f - (float)Screen.width / 8.0f / 2.0f, (float)Screen.height / 5.0f + (float)Screen.height / 30.0f, (float)Screen.width / 8.0f, 35.0f), "Repositories"); GUI.Label(new Rect((float)Screen.width / 15.0f + (float)Screen.width / 35.0f * 1.5f + (float)Screen.width / 4.5f + (float)Screen.width / 4.1f / 2.0f - (float)Screen.width / 8.0f / 2.0f, (float)Screen.height / 5.0f + (float)Screen.height / 30.0f, (float)Screen.width / 8.0f, 35.0f), "Downloadable Mods"); GUI.Label(new Rect((float)Screen.width / 15.0f * 9.5f + (float)Screen.width / 35.0f + ((float)Screen.width / 15.0f * 4.5f - (float)Screen.width / 35.0f * 2.0f) / 2.0f - (float)Screen.width / 8.0f / 2.0f, (float)Screen.height / 5.0f + (float)Screen.height / 30.0f, (float)Screen.width / 8.0f, 35.0f), "Installed Mods"); GUI.skin.label.fontSize = 18; if (GUI.Button(new Rect((float)Screen.width / 15.0f + (float)Screen.width / 35.0f, (float)Screen.height / 5.0f + (float)Screen.height / 30.0f + (float)Screen.height / 6.0f * 4.0f - (float)Screen.height / 15.0f - 80.0f, (float)Screen.width / 9.0f - 1.0f, (float)Screen.width / 35.0f), string.Empty)) { //App.Popups.ShowTextEntry (this, "http://", "WARNING: Other repositories are NOT trusted by Scrollsguide.", "addRepo", "Add Repository", "Please enter the URL of the repository you want to add", "Add"); App.Popups.ShowTextEntry(this, "addRepo", "Add Repository", "WARNING: Other repositories are NOT trusted by Scrollsguide.", "Add", "Please enter the URL of the repository you want to add", "http://"); } GUI.Label(new Rect((float)Screen.width / 15.0f + (float)Screen.width / 35.0f, (float)Screen.height / 5.0f + (float)Screen.height / 30.0f + (float)Screen.height / 6.0f * 4.0f - (float)Screen.height / 15.0f - 80.0f, (float)Screen.width / 9.0f - 1.0f, (float)Screen.width / 35.0f), "Add Repository"); if (GUI.Button(new Rect((float)Screen.width / 15.0f + (float)Screen.width / 35.0f + (float)Screen.width / 9.0f + 1.0f, (float)Screen.height / 5.0f + (float)Screen.height / 30.0f + (float)Screen.height / 6.0f * 4.0f - (float)Screen.height / 15.0f - 80.0f, (float)Screen.width / 9.0f - 1.0f, (float)Screen.width / 35.0f), string.Empty)) { try { if (repoListPopup.selectedItem().Equals(repoManager.repositories[0])) { App.Popups.ShowOk(this, "remWarning", "Invalid Operation", "You cannot remove Scrollsguide from your repository list", "OK"); } else { repoManager.removeRepository((Repo)repoListPopup.selectedItem()); repoListPopup.SetItemList(repoManager.repositories); repoListPopup.setSelectedItem(repoManager.repositories[0]); downloadableListPopup.SetItemList(repoManager.getModListForRepo((Repo)repoListPopup.selectedItem())); } } catch {} } GUI.Label(new Rect((float)Screen.width / 15.0f + (float)Screen.width / 35.0f + (float)Screen.width / 9.0f + 1.0f, (float)Screen.height / 5.0f + (float)Screen.height / 30.0f + (float)Screen.height / 6.0f * 4.0f - (float)Screen.height / 15.0f - 80.0f, (float)Screen.width / 9.0f - 1.0f, (float)Screen.width / 35.0f), "Remove Repository"); if (GUI.Button(new Rect((float)Screen.width / 15.0f + (float)Screen.width / 35.0f * 1.5f + (float)Screen.width / 4.5f, (float)Screen.height / 5.0f + (float)Screen.height / 30.0f + (float)Screen.height / 6.0f * 4.0f - (float)Screen.height / 15.0f - 80.0f, (float)Screen.width / 4.1f, (float)Screen.width / 35.0f), string.Empty)) { App.Popups.ShowInfo("Downloading", "Please wait while the requested mods are being downloaded"); new Thread(downloadMods).Start(); } GUI.Label(new Rect((float)Screen.width / 15.0f + (float)Screen.width / 35.0f * 1.5f + (float)Screen.width / 4.5f, (float)Screen.height / 5.0f + (float)Screen.height / 30.0f + (float)Screen.height / 6.0f * 4.0f - (float)Screen.height / 15.0f - 80.0f, (float)Screen.width / 4.1f, (float)Screen.width / 35.0f), "Download"); if (GUI.Button(new Rect((float)Screen.width / 15.0f * 9.5f + (float)Screen.width / 35.0f, (float)Screen.height / 5.0f + (float)Screen.height / 30.0f + (float)Screen.height / 6.0f * 4.0f - (float)Screen.height / 15.0f - 80.0f, (float)Screen.width / 15.0f * 4.5f - (float)Screen.width / 35.0f * 2.0f, (float)Screen.width / 35.0f), string.Empty)) { loader.repatch(); } GUI.Label(new Rect((float)Screen.width / 15.0f * 9.5f + (float)Screen.width / 35.0f, (float)Screen.height / 5.0f + (float)Screen.height / 30.0f + (float)Screen.height / 6.0f * 4.0f - (float)Screen.height / 15.0f - 80.0f, (float)Screen.width / 15.0f * 4.5f - (float)Screen.width / 35.0f * 2.0f, (float)Screen.width / 35.0f), "Apply (Restarts Scrolls)"); TextAnchor alignment = GUI.skin.label.alignment; GUI.skin.label.alignment = TextAnchor.MiddleRight; GUI.skin.label.normal.textColor = Color.Lerp(Color.white, Color.yellow, 0.4f); GUI.Label(new Rect(Screen.width * 0.5f, Screen.height * 0.90f, Screen.width * 0.48f, Screen.height * 0.04f), "The Summoner ModLoader v" + ModLoader.getVersion() + " is not an official Scrolls feature"); GUI.Label(new Rect(Screen.width * 0.5f, Screen.height * 0.94f, Screen.width * 0.48f, Screen.height * 0.04f), "Read and submit bugs on http://www.scrollsguide.com/summoner"); GUI.skin.label.normal.textColor = textColor; GUI.skin.label.fontSize = defaultTextSize; GUI.skin.label.alignment = alignment; }
public static void UnhandledExceptionHandler(object sender, UnhandledExceptionEventArgs e) { if ((e.ExceptionObject as Exception).TargetSite.Module.Assembly.GetName().Name.Equals("UnityEngine") || (e.ExceptionObject as Exception).TargetSite.Module.Assembly.GetName().Name.Equals("Assembly-CSharp") || (e.ExceptionObject as Exception).TargetSite.Module.Assembly.GetName().Name.Equals("ScrollsModLoader") || (e.ExceptionObject as Exception).TargetSite.Module.Assembly.Location.ToLower().Equals(Platform.getGlobalScrollsInstallPath().ToLower()) || (e.ExceptionObject as Exception).TargetSite.Module.Assembly.Location.Equals("")) //no location or Managed => mod loader crash //log { Console.WriteLine(e.ExceptionObject); new ExceptionLogger().logException((Exception)e.ExceptionObject); //unload ScrollsModLoader MethodBodyReplacementProviderRegistry.SetProvider(new NoMethodReplacementProvider()); //check for frequent crashes if (!System.IO.File.Exists(Platform.getGlobalScrollsInstallPath() + System.IO.Path.DirectorySeparatorChar + "check.txt")) { System.IO.File.CreateText(Platform.getGlobalScrollsInstallPath() + System.IO.Path.DirectorySeparatorChar + "check.txt"); Platform.RestartGame(); } else { try { foreach (String id in instance.modOrder) { BaseMod mod = instance.modInstances [id]; if (mod != null) { try { instance.unloadMod((LocalMod)instance.modManager.installedMods.Find(delegate(Item lmod) { return((lmod as LocalMod).id.Equals(id)); })); } catch (Exception exp) { Console.WriteLine(exp); } } } } catch (Exception exp) { Console.WriteLine(exp); } instance.repatch(); } } else if (instance != null && logger != null && logger.Count > 0) { Console.WriteLine(e.ExceptionObject); Assembly asm = (e.ExceptionObject as Exception).TargetSite.Module.Assembly; Type modClass = (from _modClass in asm.GetTypes() where _modClass.InheritsFrom(typeof(BaseMod)) select _modClass).First(); //no mod classes?? if (modClass == null) { return; } foreach (String id in instance.modOrder) { BaseMod mod = null; try { mod = instance.modInstances [id]; } catch (Exception exp) { Console.WriteLine(exp); } if (mod != null) { if (modClass.Equals(mod.GetType())) { String folder = Path.GetDirectoryName(asm.Location); if (File.Exists(folder + Path.DirectorySeparatorChar + "config.json")) { JsonReader reader = new JsonReader(); LocalMod lmod = (LocalMod)reader.Read(File.ReadAllText(folder + Path.DirectorySeparatorChar + "config.json"), typeof(LocalMod)); if (!lmod.localInstall) { logger [lmod.localId].logException((Exception)e.ExceptionObject); } } } } } } }