Exemplo n.º 1
0
        public Form1(string ror2Path, bool nolaunch, bool hd, bool startWithDownload)
        {
            _hd = hd;
            if (ror2Path == null || ror2Path == "" || ror2Path == "#UNKNOWN#")
            {
                throw new ArgumentException();
            }
            else
            {
                this._ror2Path = ror2Path;
            }
            InitializeComponent();
            this._mods = LoadPackages();
            string p = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "uritemp");

            if (startWithDownload && File.Exists(p))
            {
                Console.WriteLine("Download requested from url protocol ...");
                StreamReader sr = new StreamReader(File.OpenRead(p));
                Install(sr.ReadLine());
                sr.Close();
                sr.Dispose();
                File.Delete(p);
            }
            else
            {
                ListPackages();
            }
            Console.WriteLine("Done loading.");
            if (this._mods.THIS_MOD.GetLatestVersion().VersionNumber.IsNewer(this._mods.THIS_VN))
            {
                DialogResult res = MessageBox.Show("There's a new version of Risk of Death available. Would you like to update the app now?", "Update now?", MessageBoxButtons.YesNo);
                if (res == DialogResult.Yes)
                {
                    //Install update
                    UpdateRoD(null, null);
                }
                else
                {
                    ToolStripMenuItem item = new ToolStripMenuItem
                    {
                        Name     = "updateMeToolStripMenuItem",
                        AutoSize = true,
                        Text     = "Update RoD"
                    };
                    item.Click += new EventHandler(this.UpdateRoD);
                    this.menuStrip1.Items.Add(item);
                }
            }
            WriteRoamingFiles();
            if (nolaunch)
            {
                this.launchBtn.Enabled = false;
                this.launchBtn.Visible = false;
            }
            protocolBackgroundWorker.RunWorkerAsync();
        }
Exemplo n.º 2
0
        private ModContainer LoadPackages()
        {
            WebRequest   req  = WebRequest.Create(THUNDERSTORE_PKG);
            WebResponse  resp = req.GetResponse();
            StreamReader sr   = new StreamReader(resp.GetResponseStream());
            ModContainer ret  = new ModContainer(sr.ReadToEnd(), this._ror2Path);

            sr.Close();
            sr.Dispose();
            return(ret);
        }