Exemplo n.º 1
0
        protected void OnInstallUpdateButtonClicked(object sender, EventArgs e)
        {
            string pathToLuaScriptsLib = Program.ProgramSettings.LunaLuaDirectory + System.IO.Path.DirectorySeparatorChar + "LuaScriptsLib";
            if (m.LuaURL != null || m.LuaURL != "NULL")
            {
                string toSaveToFileName = m.LuaURL.Substring(m.LuaURL.LastIndexOf("/")).Trim('/');

                Downloader d = new Downloader(m.LuaURL, pathToLuaScriptsLib + System.IO.Path.DirectorySeparatorChar + toSaveToFileName);
                d.Show();
                d.BeginDownload();
                while (d.Downloading)
                    ;
            }
            if (m.ResURL != "NULL")
            {
                string toSaveToFileName = m.ResURL.Substring(m.LuaURL.LastIndexOf("/")).Trim('/');

                Downloader d = new Downloader(m.ResURL, pathToLuaScriptsLib + System.IO.Path.DirectorySeparatorChar + toSaveToFileName, true);
                d.Show();
                d.BeginDownload();
                while (d.Downloading)
                    ;
            }
            Refresh();
        }
        protected void OnButton2Clicked(object sender, EventArgs e)
        {
            //http://engine.wohlnet.ru/LunaLua/get.php?luaver=-1&installationType=Full&base=smbx13&fbase=1
            if (Internals.CurrentOS == InternalOperatingSystem.Linux)
            {
                MessageDialog md = new MessageDialog(null,
                                       DialogFlags.Modal,
                                       MessageType.Question,
                                       ButtonsType.YesNo,
                                       "It is highly recommended that you use my PlayOnLinux script for direct support from me\nregarding running LunaLua under Linux.\n\nWould you like to get my PlayOnLinux script? \n(Hitting no will bring you to the manual LunaLua download)");
                md.Icon = Image.LoadFromResource("Gtktester.Icons.PNG.256.png").Pixbuf;
                int returnVal = md.Run();
                if (returnVal == -8)
                {
                    Process.Start("https://www.playonlinux.com/en/topic-13294-Script_Super_Mario_Bros_X.html");
                }
                else
                    Process.Start("http://engine.wohlnet.ru/LunaLua");
                Console.WriteLine(returnVal);
                md.Destroy();
            }
            else if (Internals.CurrentOS == InternalOperatingSystem.Windows)
            {
                string extractTo = @"C:\SMBX";
                if (entry1.Text.Trim() == "")
                {
                    MessageDialog md = new MessageDialog(null, DialogFlags.Modal, MessageType.Info,
                                           ButtonsType.OkCancel, "You've left the LunaLua Directory blank. By doing this, LunaLua will be installed to 'C:\\SMBX'.\n\nIf this is not okay, please click cancel and select the path you'd like to download LunaLua to.");
                    md.Icon = Image.LoadFromResource("Gtktester.Icons.PNG.256.png").Pixbuf;
                    md.WindowPosition = WindowPosition.Center;
                    ResponseType res = (ResponseType)md.Run();
                    md.Destroy();
                    if (res == ResponseType.Ok)
                    {
                    }
                    else
                        return;
                }
                else
                    extractTo = entry1.Text;

                if (!Directory.Exists(Program.ProgramSettings.ConfigDirectory + System.IO.Path.DirectorySeparatorChar + "temp"))
                    Directory.CreateDirectory(Program.ProgramSettings.ConfigDirectory + System.IO.Path.DirectorySeparatorChar + "temp");
                Downloader d = new Downloader("http://engine.wohlnet.ru/LunaLua/get.php?luaver=-1&installationType=Full&base=smbx13&fbase=1", Program.ProgramSettings.ConfigDirectory + System.IO.Path.DirectorySeparatorChar + "temp" + "\\lunalua.zip", true, extractTo);
                d.BeginDownload();

                entry1.Text = extractTo;
            }
        }
        /// <summary>
        /// Updates LunaLua ONLY.
        /// </summary>
        public void UpdateLunaLua()
        {
            if (!Directory.Exists(Program.ProgramSettings.ConfigDirectory+ System.IO.Path.DirectorySeparatorChar + "temp"))
                Directory.CreateDirectory(Program.ProgramSettings.ConfigDirectory + System.IO.Path.DirectorySeparatorChar + "temp");

            string url = String.Format("http://engine.wohlnet.ru/LunaLua/get.php?luaver={0}&installationType=Update&base=smbx13&fbase=1", wohlId);
            Downloader d = new Downloader(url, Program.ProgramSettings.ConfigDirectory + System.IO.Path.DirectorySeparatorChar + "temp" + System.IO.Path.DirectorySeparatorChar + "lunalua.zip", true, Program.ProgramSettings.LunaLuaDirectory);
            d.BeginDownload();
            d.Destroyed += (object sender, EventArgs e) => {RefreshView();};
        }