Beispiel #1
0
            public override void ProcessServerInfo(ServerQuerier.SRB2ServerInfo srb2si)
            {
                ListView lv = form1.listViewServers;

                // Build a list item.
                ListViewItem lvi = new ListViewItem(srb2si.strName);

                // So we can get address and whatever else we might need.
                lvi.Tag = srb2si;

                // Gametype string, or number if not recognised.
                if (dicGametypes.ContainsKey(srb2si.byGametype))
                {
                    lvi.SubItems.Add(dicGametypes[srb2si.byGametype]);
                }
                else
                {
                    lvi.SubItems.Add(Convert.ToString(srb2si.byGametype));
                }

                lvi.SubItems.Add(Convert.ToString(srb2si.uiTime));
                lvi.SubItems.Add(srb2si.byPlayers + "/" + srb2si.byMaxplayers);
                lvi.SubItems.Add(srb2si.strVersion);

                // Make the tooltip.
                BuildTooltip(lvi, form1.settings.ShowDefaultWads);

                // Is the game full?
                if (srb2si.byPlayers >= srb2si.byMaxplayers)
                {
                    lvi.ForeColor = Color.DimGray;
                }
                // Modified?
                else if (srb2si.bModified)
                {
                    lvi.ForeColor = Color.Red;
                }

                // Thread-safe goodness.
                if (lv.InvokeRequired)
                {
                    // Call ourselves in the context of the form's thread.
                    AddToListCallback addtolistcallback = new AddToListCallback(lv.Items.Add);
                    lv.Invoke(addtolistcallback, new object[] { lvi });
                }
                else
                {
                    // Add it!
                    lv.Items.Add(lvi);
                }
            }
Beispiel #2
0
        private void ConnectToServerFromListItem(ListViewItem lvi)
        {
            ServerQuerier.SRB2ServerInfo srb2si = (ServerQuerier.SRB2ServerInfo)lvi.Tag;

            // Prompt to get a binary if we need one.
            if (!settings.HasBinaryForVersion(srb2si.strVersion) &&
                MessageBox.Show("To join this game, you must register an executable file for version " + srb2si.strVersion + ". Would you like to do so?", Text, MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation) == DialogResult.Yes &&
                openFileDialog1.ShowDialog() == DialogResult.OK)
            {
                settings.SetBinary(srb2si.strVersion, openFileDialog1.FileName);
                settings.SaveSettings();
            }

            // Go!
            ConnectToServer(srb2si.strAddress, srb2si.unPort, srb2si.strVersion);
        }
Beispiel #3
0
            public static void BuildTooltip(ListViewItem lvi, bool bShowDefaultWads)
            {
                string strWads = String.Empty;

                ServerQuerier.SRB2ServerInfo srb2si = (ServerQuerier.SRB2ServerInfo)lvi.Tag;

                foreach (ServerQuerier.AddedWad aw in srb2si.listFiles)
                {
                    List <string> listDefaultFiles = dicDefaultFiles[srb2si.siv];

                    if (bShowDefaultWads || !listDefaultFiles.Contains(aw.strFilename))
                    {
                        strWads += String.Format("\n{0} ({1:f1} KB)", aw.strFilename, Convert.ToSingle(aw.uiSize) / 1024);
                        if (aw.bImportant)
                        {
                            if (aw.downloadtype == ServerQuerier.DownloadTypes.DT_TOOBIG)
                            {
                                strWads += " (too big to download)";
                            }
                            else if (aw.downloadtype == ServerQuerier.DownloadTypes.DT_DISABLED)
                            {
                                strWads += " (downloading disabled)";
                            }
                        }
                        else
                        {
                            strWads += " (unimportant)";
                        }
                    }
                }

                lvi.ToolTipText = "Current map: " + srb2si.strMapName + "\n";
                if (strWads != String.Empty)
                {
                    lvi.ToolTipText += "Wads added:" + strWads;
                }
                else
                {
                    lvi.ToolTipText += "No wads added";
                }
            }