コード例 #1
0
ファイル: PageHandlers.cs プロジェクト: uotools/cuodesktop
        private static void OnResetPatchesRequested(string request, PageCompiler compiler, ref Socket socket)
        {
            string id    = Utility.ParseUrl(request, "id");
            IEntry entry = ServerList.GetServerById(id);

            if (entry != null && MessageBox.Show("Are you sure you want to reset patches for " + entry.Name + "?", "ConnectUO Desktop", System.Windows.Forms.MessageBoxButtons.YesNo, System.Windows.Forms.MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.Yes)
            {
                string name = Uri.EscapeDataString(entry.Name);
                string path = Path.Combine(AppSettings.Current.Get <string>("PatchingPath"), Path.Combine("Servers", name));

                if (Directory.Exists(path))
                {
                    bool success = true;
                    try
                    {
                        Directory.Delete(path, true);
                    }
                    catch
                    {
                        success = false;
                    }

                    if (success)
                    {
                        MessageBox.Show("Patches for " + entry.Name + " were reset successfully.", "ConnectUO Desktop");
                    }
                    else
                    {
                        MessageBox.Show("An error occurred while trying to reset the patches for " + entry.Name + ".\n This can be caused by the client still running or some other application that is currently using\n the files in the patch directory for this server.\n Please be sure that nothing is accessing these files and try again.", "ConnectUO Desktop");
                    }
                }
            }

            Core.Server.SendToBrowser(String.Format(Utility.META_REDIRECT, "http://localhost.:1980/favorites.html"), ref socket);
        }
コード例 #2
0
        private void MainForm_Load(object sender, EventArgs e)
        {
            _instance = this;

            MainForm.Instance.notifyIcon.ShowBalloonTip(10, "Serverlist", "Loading please wait...", ToolTipIcon.Info);
            ServerList.LoadServerList();
            MainForm.Instance.notifyIcon.ShowBalloonTip(10, "Serverlist", "Complete", ToolTipIcon.Info);

            if (DateTime.Now > Properties.Settings.Default.NextUpdateTime)
            {
                CheckForUpdates();
            }

            Properties.Settings.Default.SettingChanging += new System.Configuration.SettingChangingEventHandler(Default_SettingChanging);

            if (Properties.Settings.Default.RazorPath == "Not Installed")
            {
                Properties.Settings.Default.RazorPath = Utility.DetectRazor();
            }

            if (Properties.Settings.Default.ClientPath == "Not Installed")
            {
                Properties.Settings.Default.ClientPath = Utility.DetectClient("Ultima Online");
            }

            if (Properties.Settings.Default.ClientPath == "Not Installed")
            {
                Properties.Settings.Default.ClientPath = Utility.DetectClient("Ultima Online Third Dawn");
            }

            if (Properties.Settings.Default.OpenBrowserOnStartup)
            {
                Utility.OpenUrl(Core.StartAddress);
            }
        }
コード例 #3
0
 private void updateServerlistToolStripMenuItem_Click(object sender, EventArgs e)
 {
     if (!ServerList.Updating)
     {
         ServerList.Update();
     }
 }
コード例 #4
0
ファイル: MainForm.cs プロジェクト: uotools/cuodesktop
        public void addLocalServerToolStripMenuItem_Click(object sender, EventArgs e)
        {
            AddLocalServerDialog d = new AddLocalServerDialog();

            d.Opacity = GetOpacity("AddLocalOpacity");

            bool editmode = (sender != null && sender is object[]);

            d.EditMode = editmode;
            CustomEntry en = null;

            if (editmode)
            {
                string request = (string)((object[])sender)[0];
                Socket socket  = (Socket)((object[])sender)[1];

                en = (CustomEntry)ServerList.GetServerById(Utility.ParseUrl(request, "id"));

                if (en == null)
                {
                    MessageBox.Show("The requested server entry was invalid or did not exist");
                    Core.Server.SendToBrowser(String.Format(Utility.META_REDIRECT, "http://localhost.:1980/favorites.html"), ref socket);
                    //Utility.OpenUrl("http://localhost.:1980/favorites");
                    return;
                }

                d.ServerName        = en.Name;
                d.ServerDescription = en.Description;
                d.ServerAddress     = en.HostAddress;
                d.ServerPort        = en.Port.ToString();
                d.ServerUpdateURL   = en.UpdateUrl;
                d.ServerPatchURL    = en.PatchUrl;
                d.RemoveEnc         = en.RemoveEncryption;

                Core.Server.SendToBrowser(String.Format(Utility.META_REDIRECT, "http://localhost.:1980/favorites.html"), ref socket);
            }

            if (d.ShowDialog() == DialogResult.OK)
            {
                if (!editmode)
                {
                    en = new CustomEntry();
                }

                en.Name             = d.ServerName;
                en.Description      = d.ServerDescription;
                en.HostAddress      = d.ServerAddress;
                en.Port             = int.Parse(d.ServerPort);
                en.UpdateUrl        = d.ServerUpdateURL;
                en.PatchUrl         = d.ServerPatchURL;
                en.RemoveEncryption = d.RemoveEnc;

                Favorites.AddCustom(en);
                Utility.OpenUrl("http://localhost.:1980/favorites.html");
            }
        }
コード例 #5
0
        private static void Load()
        {
            _favorites = new List <FavoriteEntry>();
            _customs   = new List <CustomEntry>();

            if (File.Exists(Path.Combine(Core.BaseDirectory, "favorites.bin")))
            {
                BinaryReader reader = new BinaryReader(new FileStream(Path.Combine(Core.BaseDirectory, "favorites.bin"), FileMode.OpenOrCreate));

                int ver = reader.ReadInt32();

                switch (ver)
                {
                case 1:
                {
                    int count = reader.ReadInt32();

                    for (int i = 0; i < count; i++)
                    {
                        CustomEntry entry = new CustomEntry();
                        entry.Deserialize(reader);
                        _customs.Add(entry);
                    }

                    goto case 0;
                }

                case 0:
                {
                    int count = reader.ReadInt32();

                    for (int i = 0; i < count; i++)
                    {
                        IEntry entry = ServerList.GetServerById(reader.ReadInt32().ToString());

                        if (entry == null)
                        {
                            continue;
                        }

                        _favorites.Add(new FavoriteEntry(entry.Element));
                    }

                    break;
                }
                }

                reader.Close();
            }
        }
コード例 #6
0
        /// <summary>
        /// Adds the server to the favorites list.
        /// </summary>
        /// <param name="id">server id</param>
        public static void AddFavorite(string id)
        {
            int value;

            if (Int32.TryParse(id, out value) && !FavoriteExists(value))
            {
                IEntry entry = ServerList.GetServerById(id);

                if (entry != null)
                {
                    MyFavorites.Add(new FavoriteEntry(entry.Element));
                    Save();
                }
            }
        }
コード例 #7
0
        private void EndUpdate()
        {
            _splashScreen.Status = "Loading the serverlist...";
            ServerList.LoadServerList();

            _isBusy = false;

            if (UpdateComplete != null)
            {
                UpdateComplete(this, new EventArgs());
            }

            if (_splashScreen.Visible)
            {
                _splashScreen.Invoke((MethodInvoker) delegate { _splashScreen.Close(); });
            }

            _thread.Abort();
        }
コード例 #8
0
ファイル: Utility.cs プロジェクト: uotools/cuodesktop
        /// <summary>
        /// Starts the Ultima Online client for the specified server
        /// </summary>
        /// <param name="id"></param>
        /// <param name="custom"></param>
        public static unsafe void Play(string id, string type, Socket socket)
        {
            IEntry entry = ServerList.GetServerById(id);

            if (entry == null)
            {
                System.Windows.Forms.MessageBox.Show("The server information requested was not found", "Invalid Element ID");
                Core.Server.SendToBrowser(String.Format(Utility.META_REDIRECT, "http://localhost.:1980/home.html?page=1"), ref socket);
                return;
            }

            try
            {
                string client = AppSettings.Current.Get <string>("ClientPath");
                string razor  = AppSettings.Current.Get <bool>("LoadRazor") ? AppSettings.Current.Get <string>("RazorPath") : "Not Found";

                if (client == "Not Found")
                {
                    System.Windows.Forms.MessageBox.Show("You do not appear to have Ultima Online installed.", "Ultima Online Not Found");
                    Core.Server.SendToBrowser(String.Format(Utility.META_REDIRECT, "http://localhost.:1980/home.html?page=1"), ref socket);
                    return;
                }

                if (type == "public")
                {
                    Core.Server.SendToBrowser(String.Format(Utility.META_REDIRECT, "http://localhost.:1980/home.html?page=1"), ref socket);
                }
                else
                {
                    Core.Server.SendToBrowser(String.Format(Utility.META_REDIRECT, "http://localhost.:1980/favorites.html"), ref socket);
                }

                byte[] param = new byte[257];

                MemoryStream memStream = new MemoryStream(param);
                BinaryWriter writer    = new BinaryWriter(memStream);

                if (razor != "Not Found")
                {
                    writer.Write((byte)0);                     // when razor is enabled it will remove the encryption for us
                }
                else
                {
                    writer.Write((byte)Convert.ToByte(entry.RemoveEncryption));
                }

                string patch;
                string path = BuildPatchList(entry, out patch);

                writer.Write(path.ToCharArray());

                writer.Close();
                memStream.Close();

                UInt32      pid;
                LoaderError err;

                string encPath = Path.Combine(Core.BaseDirectory, "EncPatcher.dll");

                fixed(byte *para_ptr = param)
                err = (LoaderError)Load(client, encPath, "Attach", para_ptr, param.Length, out pid);

                if (err == LoaderError.SUCCESS)
                {
                    if (pid != 0 && razor != "Not Found" && entry.AllowRazor)
                    {
                        string opts;
                        if (entry.RemoveEncryption)
                        {
                            opts = "--clientenc";
                        }
                        else
                        {
                            opts = "--clientenc --serverenc";
                        }

                        System.Diagnostics.Process.Start(razor, String.Format("{0} --pid {1}", opts, pid));

                        if (MainForm.Instance.Visible)
                        {
                            MainForm.Instance.Invoke((MethodInvoker) delegate { MainForm.Instance.WindowState = FormWindowState.Minimized; });
                        }
                    }
                }
                else
                {
                    System.Windows.Forms.MessageBox.Show(String.Format("Loader.dll ERROR: {0} (pid = {1})", err, pid));
                }
            }
            catch (Exception e)
            {
                System.Windows.Forms.MessageBox.Show(e.ToString());
                Trace.HandleException(e);
            }
        }