Skip to content

Commit

Permalink
- fixed copy&paste shortcuts
Browse files Browse the repository at this point in the history
- fixed error when a Quake Live servers has a non-integer teamsize (0.5)
- fixed servers not showing up after pasting to a manual server list
- removed option "remember column layout for each tab" (it's now always on)
  • Loading branch information
PredatH0r committed Nov 3, 2015
1 parent 25c936d commit 00e6457
Show file tree
Hide file tree
Showing 8 changed files with 132 additions and 87 deletions.
3 changes: 2 additions & 1 deletion ServerBrowser/Games/QuakeLive.cs
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,8 @@ public override string GetCleanPlayerName(Player player)
var ts = row.GetRule("teamsize");
if (!string.IsNullOrEmpty(ts))
{
var n = int.Parse(ts);
int n;
int.TryParse(ts, out n);
if (n != 0)
return n*2;
}
Expand Down
3 changes: 3 additions & 0 deletions ServerBrowser/ServerBrowser.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,9 @@
<DependentUpon>ConnectingWaitForm.cs</DependentUpon>
</Compile>
<Compile Include="Win32.cs" />
<Compile Include="XBarManager.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="XWebClient.cs" />
<EmbeddedResource Include="Games\QuakeLiveOptionsDialog.resx">
<DependentUpon>QuakeLiveOptionsDialog.cs</DependentUpon>
Expand Down
34 changes: 8 additions & 26 deletions ServerBrowser/ServerBrowserForm.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

62 changes: 26 additions & 36 deletions ServerBrowser/ServerBrowserForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ namespace ServerBrowser
{
public partial class ServerBrowserForm : XtraForm
{
private const string Version = "2.13";
private const string Version = "2.14";
private const string DevExpressVersion = "v15.1";
private const string CustomDetailColumnPrefix = "ServerInfo.";
private const string CustomRuleColumnPrefix = "custRule.";
Expand All @@ -51,7 +51,6 @@ public partial class ServerBrowserForm : XtraForm
private readonly IniFile iniFile;
private XtraTabPage dragPage;
private const int PredefinedTabCount = 2;
private List<ServerRow> filteredServers = new List<ServerRow>();

#region ctor()
public ServerBrowserForm()
Expand Down Expand Up @@ -387,7 +386,6 @@ private int ApplyAppSettingsFromIni(IniFile ini, IniFile.Section options, out st
this.cbNoUpdateWhilePlaying.Checked = !options.GetBool("AutoUpdateWhilePlaying");
this.cbFavServersOnTop.Checked = options.GetBool("KeepFavServersOnTop", true);
this.cbHideUnresponsiveServers.Checked = options.GetBool("HideUnresponsiveServers", true);
this.cbRememberColumnLayout.Checked = options.GetBool("ColumnLayoutPerTab", true);
this.cbShowFilterPanelInfo.Checked = options.GetBool("ShowFilterPanelInfo", true);
this.cbShowCounts.Checked = options.GetBool("ShowServerCounts", true);

Expand Down Expand Up @@ -464,7 +462,6 @@ protected virtual void SaveAppSettings(StringBuilder sb)
sb.AppendLine($"AutoUpdateWhilePlaying={!this.cbNoUpdateWhilePlaying.Checked}");
sb.AppendLine($"Skin={UserLookAndFeel.Default.SkinName}");
sb.AppendLine($"TabIndex={this.tabControl.SelectedTabPageIndex}");
sb.AppendLine($"ColumnLayoutPerTab={this.cbRememberColumnLayout.Checked}");
sb.AppendLine($"ShowFilterPanelInfo={this.cbShowFilterPanelInfo.Checked}");
sb.AppendLine($"ShowServerCounts={this.cbShowCounts.Checked}");

Expand Down Expand Up @@ -561,12 +558,9 @@ protected virtual void UpdateViewModel()
vm.TagsExcludeClient = this.btnTagExcludeClient.Text;

vm.GridFilter = this.gvServers.ActiveFilterString;
if (this.cbRememberColumnLayout.Checked)
{
var strm = new MemoryStream();
this.gvServers.SaveLayoutToStream(strm);
vm.ServerGridLayout = strm;
}
var strm = new MemoryStream();
this.gvServers.SaveLayoutToStream(strm);
vm.ServerGridLayout = strm;
vm.serverSource = this.CreateServerSource(vm.MasterServer);
vm.gameExtension = this.extenders.Get((Game)vm.InitialGameID);

Expand Down Expand Up @@ -648,18 +642,16 @@ private void InitGameExtension()
this.gvServers.BeginUpdate();
this.ResetGridColumns(this.gvServers);
this.viewModel.gameExtension.CustomizeServerGridColumns(gvServers);
if (this.cbRememberColumnLayout.Checked)
foreach (var custCol in this.viewModel.CustomDetailColumns)
{
foreach (var custCol in this.viewModel.CustomDetailColumns)
{
var col = this.viewModel.gameExtension.AddColumn(this.gvServers, CustomDetailColumnPrefix + custCol, custCol, null);
col.UnboundType = UnboundColumnType.Bound;
}
foreach (var custCol in this.viewModel.CustomRuleColumns)
this.viewModel.gameExtension.AddColumn(this.gvServers, CustomRuleColumnPrefix + custCol, custCol, null);
var col = this.viewModel.gameExtension.AddColumn(this.gvServers, CustomDetailColumnPrefix + custCol, custCol, null);
col.UnboundType = UnboundColumnType.Bound;
}
foreach (var custCol in this.viewModel.CustomRuleColumns)
this.viewModel.gameExtension.AddColumn(this.gvServers, CustomRuleColumnPrefix + custCol, custCol, null);
this.gvServers.EndUpdate();
if (viewModel.ServerGridLayout != null && this.cbRememberColumnLayout.Checked)

if (viewModel.ServerGridLayout != null)
{
viewModel.ServerGridLayout.Seek(0, SeekOrigin.Begin);
this.gvServers.RestoreLayoutFromStream(viewModel.ServerGridLayout);
Expand Down Expand Up @@ -732,8 +724,8 @@ private void RefreshServerInfo()
return;
this.miStopUpdate.Enabled = true;
this.timerReloadServers.Stop();
this.SetStatusMessage("Updating status of " + this.filteredServers.Count + " servers...");
this.queryLogic.RefreshAllServers(this.filteredServers);
this.SetStatusMessage("Updating status of " + this.viewModel.servers.Count + " servers...");
this.queryLogic.RefreshAllServers(this.viewModel.servers);
if (this.spinRefreshInterval.Value > 0)
this.timerReloadServers.Start();
}
Expand Down Expand Up @@ -846,24 +838,14 @@ protected void UpdateViews(bool forceUpdateDetails = false)
this.LookupGeoIps();
this.UpdateCachedServerNames();

//this.filteredServers.Clear();
//if (this.viewModel.servers != null)
//{
// if (this.cbHideUnresponsiveServers.Checked)
// this.filteredServers.AddRange(this.viewModel.servers.Where(s => s.ServerInfo != null && s.ServerInfo.Ping != 0 && !s.Status.StartsWith("Timeout")));
// else
// this.filteredServers.AddRange(this.viewModel.servers);
//}
//this.gcServers.DataSource = filteredServers; // always use the same object reference, otherwise all state (top-row, focused, selected) would get lost
this.filteredServers = this.viewModel.servers;
this.gcServers.DataSource = this.viewModel.servers;
this.gvServers.EndDataUpdate();
//this.gvServers.RefreshData();

if (this.viewModel.lastSelectedServer != null)
{
int i = 0;
foreach (var server in filteredServers)
foreach (var server in this.viewModel.servers)
{
if (server.EndPoint.Equals(this.viewModel.lastSelectedServer.EndPoint))
{
Expand Down Expand Up @@ -1537,9 +1519,10 @@ private void txtGameServer_ButtonClick(object sender, ButtonPressedEventArgs e)
serverRow = new ServerRow(endpoint, this.extenders.Get(0));
this.viewModel.servers.Add(serverRow);
this.gvServers.EndDataUpdate();
serverRow.SetModified();
var handle = this.gvServers.GetRowHandle(this.viewModel.servers.Count - 1);
this.gvServers.FocusedRowHandle = handle;
this.gvServers.SelectRow(handle);
this.gvServers.SelectRow(handle);
}
this.queryLogic.RefreshSingleServer(serverRow);
}
Expand Down Expand Up @@ -1658,7 +1641,7 @@ private void timerUpdateServerList_Tick(object sender, EventArgs e)
#region gvServers_CustomRowFilter
private void gvServers_CustomRowFilter(object sender, RowFilterEventArgs e)
{
var row = this.filteredServers[e.ListSourceRow];
var row = this.viewModel.servers[e.ListSourceRow];

if (FilterServerRow(row))
{
Expand Down Expand Up @@ -1922,6 +1905,8 @@ private void miPasteAddress_ItemClick(object sender, ItemClickEventArgs e)
{
if (this.viewModel.Source != TabViewModel.SourceType.CustomList)
return;
this.gvServers.BeginDataUpdate();

try
{
var text = Clipboard.GetText();
Expand All @@ -1934,14 +1919,19 @@ private void miPasteAddress_ItemClick(object sender, ItemClickEventArgs e)
var endpoint = Ip4Utils.ParseEndpoint(addr);
var row = this.viewModel.servers.FirstOrDefault(r => r.EndPoint.Equals(endpoint));
if (row == null)
this.viewModel.servers.Add(new ServerRow(endpoint, unknownGame));
{
row = new ServerRow(endpoint, unknownGame);
row.SetModified();
this.viewModel.servers.Add(row);
this.queryLogic.RefreshSingleServer(row);
}
}
}
}
catch
{
}
this.UpdateViews();
this.gvServers.EndDataUpdate();
}
#endregion

Expand Down
Loading

0 comments on commit 00e6457

Please sign in to comment.