Fixed handling offline servers.
Fixed handling offline servers and "Hide offline servers" checkbox, now we will hide servers that was online but went offline properly.
This commit is contained in:
parent
cc20dca39c
commit
4421e29695
@ -421,6 +421,7 @@ func (m *MainWindow) loadAllServers() {
|
|||||||
// ToDo: do it without clearing.
|
// ToDo: do it without clearing.
|
||||||
for _, server := range ctx.Cache.Servers {
|
for _, server := range ctx.Cache.Servers {
|
||||||
iter := new(gtk.TreeIter)
|
iter := new(gtk.TreeIter)
|
||||||
|
ping, _ := strconv.Atoi(server.Server.Ping)
|
||||||
|
|
||||||
if !server.AllServersIterSet {
|
if !server.AllServersIterSet {
|
||||||
server.AllServersIter = iter
|
server.AllServersIter = iter
|
||||||
@ -429,7 +430,7 @@ func (m *MainWindow) loadAllServers() {
|
|||||||
iter = server.AllServersIter
|
iter = server.AllServersIter
|
||||||
}
|
}
|
||||||
|
|
||||||
if m.all_servers_hide_offline.GetActive() && server.Server.Players == "" && server.Server.Maxplayers == "" {
|
if m.all_servers_hide_offline.GetActive() && (server.Server.Players == "" && server.Server.Maxplayers == "" || ping > 9000) {
|
||||||
if server.AllServersIterInList {
|
if server.AllServersIterInList {
|
||||||
m.all_servers_store.Remove(iter)
|
m.all_servers_store.Remove(iter)
|
||||||
server.AllServersIterInList = false
|
server.AllServersIterInList = false
|
||||||
@ -442,11 +443,15 @@ func (m *MainWindow) loadAllServers() {
|
|||||||
server.AllServersIterInList = true
|
server.AllServersIterInList = true
|
||||||
}
|
}
|
||||||
|
|
||||||
if server.Server.Name == "" && server.Server.Players == "" && server.Server.Maxplayers == "" {
|
if server.Server.Name == "" && server.Server.Players == "" {
|
||||||
m.all_servers_store.SetValue(iter, 0, m.server_offline_pic.GPixbuf)
|
m.all_servers_store.SetValue(iter, 0, m.server_offline_pic.GPixbuf)
|
||||||
m.all_servers_store.SetValue(iter, m.column_pos["Servers"]["IP"], server.Server.Ip + ":" + server.Server.Port)
|
m.all_servers_store.SetValue(iter, m.column_pos["Servers"]["IP"], server.Server.Ip + ":" + server.Server.Port)
|
||||||
|
} else {
|
||||||
|
if ping > 9000 {
|
||||||
|
m.all_servers_store.SetValue(iter, 0, m.server_offline_pic.GPixbuf)
|
||||||
} else {
|
} else {
|
||||||
m.all_servers_store.SetValue(iter, 0, m.server_online_pic.GPixbuf)
|
m.all_servers_store.SetValue(iter, 0, m.server_online_pic.GPixbuf)
|
||||||
|
}
|
||||||
if server.Server.IsPrivate == "1" {
|
if server.Server.IsPrivate == "1" {
|
||||||
m.all_servers_store.SetValue(iter, 1, m.server_passworded_pic.GPixbuf)
|
m.all_servers_store.SetValue(iter, 1, m.server_passworded_pic.GPixbuf)
|
||||||
} else {
|
} else {
|
||||||
@ -468,6 +473,7 @@ func (m *MainWindow) loadFavoriteServers() {
|
|||||||
fmt.Println("Loading favorite servers...")
|
fmt.Println("Loading favorite servers...")
|
||||||
for _, server := range ctx.Cache.Servers {
|
for _, server := range ctx.Cache.Servers {
|
||||||
iter := new(gtk.TreeIter)
|
iter := new(gtk.TreeIter)
|
||||||
|
ping, _ := strconv.Atoi(server.Server.Ping)
|
||||||
|
|
||||||
if !server.FavServersIterSet {
|
if !server.FavServersIterSet {
|
||||||
server.FavServersIter = iter
|
server.FavServersIter = iter
|
||||||
@ -476,7 +482,7 @@ func (m *MainWindow) loadFavoriteServers() {
|
|||||||
iter = server.FavServersIter
|
iter = server.FavServersIter
|
||||||
}
|
}
|
||||||
|
|
||||||
if m.fav_servers_hide_offline.GetActive() && server.Server.Players == "" && server.Server.Maxplayers == "" {
|
if m.fav_servers_hide_offline.GetActive() && (server.Server.Players == "" && server.Server.Maxplayers == "" || ping > 9000) {
|
||||||
if server.FavServersIterInList {
|
if server.FavServersIterInList {
|
||||||
m.fav_servers_store.Remove(iter)
|
m.fav_servers_store.Remove(iter)
|
||||||
server.FavServersIterInList = false
|
server.FavServersIterInList = false
|
||||||
@ -505,8 +511,12 @@ func (m *MainWindow) loadFavoriteServers() {
|
|||||||
if server.Server.Name == "" && server.Server.Players == "" {
|
if server.Server.Name == "" && server.Server.Players == "" {
|
||||||
m.fav_servers_store.SetValue(iter, 0, m.server_offline_pic.GPixbuf)
|
m.fav_servers_store.SetValue(iter, 0, m.server_offline_pic.GPixbuf)
|
||||||
m.fav_servers_store.SetValue(iter, m.column_pos["Favorites"]["IP"], server.Server.Ip + ":" + server.Server.Port)
|
m.fav_servers_store.SetValue(iter, m.column_pos["Favorites"]["IP"], server.Server.Ip + ":" + server.Server.Port)
|
||||||
|
} else {
|
||||||
|
if ping > 9000 {
|
||||||
|
m.fav_servers_store.SetValue(iter, 0, m.server_offline_pic.GPixbuf)
|
||||||
} else {
|
} else {
|
||||||
m.fav_servers_store.SetValue(iter, 0, m.server_online_pic.GPixbuf)
|
m.fav_servers_store.SetValue(iter, 0, m.server_online_pic.GPixbuf)
|
||||||
|
}
|
||||||
if server.Server.IsPrivate == "1" {
|
if server.Server.IsPrivate == "1" {
|
||||||
m.fav_servers_store.SetValue(iter, 1, m.server_passworded_pic.GPixbuf)
|
m.fav_servers_store.SetValue(iter, 1, m.server_passworded_pic.GPixbuf)
|
||||||
} else {
|
} else {
|
||||||
|
Reference in New Issue
Block a user