void GetSelectedServer(int mouseX, int mouseY) { for (int i = 0; i < Count; i++) { TableEntry entry = usedEntries[i]; if (mouseY < entry.Y || mouseY >= entry.Y + entry.Height + 2) { continue; } if (lastIndex == i && (DateTime.UtcNow - lastPress).TotalSeconds < 1) { Window.ConnectToServer(servers, entry.Hash); lastPress = DateTime.MinValue; return; } SetSelected(i); NeedRedraw(); break; } }
public void SetEntries(List <ServerListEntry> servers) { entries = new TableEntry[servers.Count]; usedEntries = new TableEntry[servers.Count]; this.servers = servers; int index = 0; foreach (ServerListEntry e in servers) { TableEntry tableEntry = default(TableEntry); tableEntry.Hash = e.Hash; tableEntry.Name = e.Name; tableEntry.Players = e.Players + "/" + e.MaximumPlayers; tableEntry.Software = e.Software; tableEntry.Uptime = MakeUptime(e.Uptime); entries[index] = tableEntry; usedEntries[index] = tableEntry; index++; } Count = entries.Length; }
public void SetEntries(List <ServerListEntry> servers) { entries = new TableEntry[servers.Count]; order = new int[servers.Count]; this.servers = servers; for (int i = 0; i < servers.Count; i++) { ServerListEntry e = servers[i]; TableEntry tableEntry = default(TableEntry); tableEntry.Hash = e.Hash; tableEntry.Name = e.Name; tableEntry.Players = e.Players + "/" + e.MaxPlayers; tableEntry.Software = e.Software; tableEntry.Uptime = MakeUptime(e.Uptime); tableEntry.RawUptime = e.Uptime; tableEntry.Featured = e.Featured; tableEntry.Flag = e.Flag; entries[i] = tableEntry; order[i] = i; } Count = entries.Length; }
static string FilterPlayers(TableEntry e) { return(e.Players); }
// cache to avoid allocations every redraw static string FilterName(TableEntry e) { return(e.Name); }
static string FilterSoftware(TableEntry e) { return(e.Software); }
static string FilterUptime(TableEntry e) { return(e.Uptime); }
bool DrawColumnEntry( IDrawer2D drawer, ref DrawTextArgs args, int maxWidth, int x, ref int y, ref TableEntry entry) { Size size = drawer.MeasureSize( ref args ); bool empty = args.Text == ""; if( empty ) size.Height = entryHeight; if( y + size.Height > table.Y + table.Height ) { y = table.Y + table.Height + 2; return false; } entry.Y = y; entry.Height = size.Height; if( !empty ) { size.Width = Math.Min( maxWidth, size.Width ); args.SkipPartsCheck = false; drawer.DrawClippedText( ref args, x, y, maxWidth, 30 ); } y += size.Height + 2; return true; }
public void SetEntries( List<ServerListEntry> servers ) { entries = new TableEntry[servers.Count]; usedEntries = new TableEntry[servers.Count]; this.servers = servers; int index = 0; foreach( ServerListEntry e in servers ) { TableEntry tableEntry = default(TableEntry); tableEntry.Hash = e.Hash; tableEntry.Name = e.Name; tableEntry.Players = e.Players + "/" + e.MaximumPlayers; tableEntry.Software = e.Software; tableEntry.Uptime = MakeUptime( e.Uptime ); entries[index] = tableEntry; usedEntries[index] = tableEntry; index++; } Count = entries.Length; }