Esempio n. 1
0
        //initial game callback
        public static void Init()
        {
            //wiredly App.Awake() calls Init multiple times, but we do not want multiple instances
            if (init)
            {
                return;
            }
            init = true;

            Console.WriteLine("ModLoader version: " + ModLoader.getVersion());

            if (Updater.tryUpdate())                //update
            {
                Application.Quit();
                return;
            }

            //Install global mod exception helper
            AppDomain.CurrentDomain.UnhandledException += UnhandledExceptionHandler;

            instance = new ModLoader();
            MethodBodyReplacementProviderRegistry.SetProvider(new SimpleMethodReplacementProvider(instance));

            //otherwise we can finally load
            instance.loadMods();

            //delete checks for loading crashes
            if (System.IO.File.Exists(Platform.getGlobalScrollsInstallPath() + System.IO.Path.DirectorySeparatorChar + "check.txt"))
            {
                System.IO.File.Delete(Platform.getGlobalScrollsInstallPath() + System.IO.Path.DirectorySeparatorChar + "check.txt");
            }
        }
Esempio n. 2
0
        // modloader errors can be constructed without parameters
        public ExceptionLogger()
        {
            this.version = ModLoader.getVersion();
            this.url     = "http://mods.scrollsguide.com";

            this.type = ExceptionType.MODLOADER;
        }
Esempio n. 3
0
        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;
        }
Esempio n. 4
0
        private static byte[] token = new byte[] { 8, 95, 174, 161, 22, 41, 180, 133 };         //public key

        public static bool tryUpdate()
        {
            WebClientTimeOut client = new WebClientTimeOut();
            String           versionMessageRaw;

            try {
                versionMessageRaw = client.DownloadString(new Uri("http://mods.scrollsguide.com/version"));
            } catch (WebException) {
                return(false);
            }

            JsonReader     reader         = new JsonReader();
            VersionMessage versionMessage = (VersionMessage)reader.Read(versionMessageRaw, typeof(VersionMessage));

            int    version     = versionMessage.version();
            String installPath = Platform.getModLoaderPath() + Path.DirectorySeparatorChar;             //;Platform.getGlobalScrollsInstallPath () + Path.DirectorySeparatorChar + "ModLoader" + Path.DirectorySeparatorChar;

            try {
                File.Delete(installPath + "Updater.exe");
            } catch {}

            if (!System.IO.Directory.Exists(installPath))
            {
                System.IO.Directory.CreateDirectory(installPath);
            }

            if (version > ModLoader.getVersion())
            {
                byte[] asm;
                try {
                    asm = client.DownloadData(new Uri("http://mods.scrollsguide.com/download/update"));
                } catch (WebException) {
                    return(false);
                }
                File.WriteAllBytes(installPath + "Updater.exe", asm);
                if (CheckToken(installPath + "Updater.exe", token))
                {
                    try {
                        App.Popups.ShowInfo("Scrolls Summoner is updating", "Please wait while the update is being downloaded");
                        Dialogs.showNotification("Scrolls Summoner is updating", "Please wait while the update is being downloaded");
                    } catch { }

                    if (Platform.getOS() == Platform.OS.Win)
                    {
                        new Process {
                            StartInfo = { FileName = installPath + "Updater.exe", Arguments = "" }
                        }.Start();
                    }
                    else if (Platform.getOS() == Platform.OS.Mac)
                    {
                        Assembly.LoadFrom(installPath + "Updater.exe").EntryPoint.Invoke(null, new object[] { new string[] {} });
                    }
                    return(true);
                }

                try {
                    App.Popups.KillCurrentPopup();
                } catch {}
            }

            return(false);
        }