Fixed show/hide offline servers.
This commit is contained in:
parent
ceaaf67510
commit
5ad43b5613
@ -20,7 +20,10 @@ import (
|
|||||||
type Server struct {
|
type Server struct {
|
||||||
Server *datamodels.Server
|
Server *datamodels.Server
|
||||||
AllServersIter *gtk.TreeIter
|
AllServersIter *gtk.TreeIter
|
||||||
FavServersIter *gtk.TreeIter
|
|
||||||
AllServersIterSet bool
|
AllServersIterSet bool
|
||||||
|
AllServersIterInList bool
|
||||||
|
|
||||||
|
FavServersIter *gtk.TreeIter
|
||||||
FavServersIterSet bool
|
FavServersIterSet bool
|
||||||
|
FavServersIterInList bool
|
||||||
}
|
}
|
||||||
|
@ -951,23 +951,31 @@ func (m *MainWindow) loadAllServers() {
|
|||||||
fmt.Println("Loading all servers...")
|
fmt.Println("Loading all servers...")
|
||||||
// ToDo: do it without clearing.
|
// ToDo: do it without clearing.
|
||||||
for _, server := range ctx.Cache.Servers {
|
for _, server := range ctx.Cache.Servers {
|
||||||
ping, _ := strconv.Atoi(server.Server.Ping)
|
|
||||||
if m.all_servers_hide_offline.GetActive() && ping > 9999 {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
iter := new(gtk.TreeIter)
|
iter := new(gtk.TreeIter)
|
||||||
|
|
||||||
if !server.AllServersIterSet {
|
if !server.AllServersIterSet {
|
||||||
server.AllServersIter = iter
|
server.AllServersIter = iter
|
||||||
m.all_servers_store.Append(iter)
|
|
||||||
server.AllServersIterSet = true
|
server.AllServersIterSet = true
|
||||||
} else {
|
} else {
|
||||||
iter = server.AllServersIter
|
iter = server.AllServersIter
|
||||||
}
|
}
|
||||||
if server.Server.Name == "" && server.Server.Players == "" {
|
|
||||||
|
if !server.AllServersIterInList {
|
||||||
|
m.all_servers_store.Append(iter)
|
||||||
|
server.AllServersIterInList = true
|
||||||
|
}
|
||||||
|
|
||||||
|
if m.all_servers_hide_offline.GetActive() && server.Server.Players == "" && server.Server.Maxplayers == "" {
|
||||||
|
m.all_servers_store.Remove(iter)
|
||||||
|
server.AllServersIterInList = false
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
if server.Server.Name == "" && server.Server.Players == "" && server.Server.Maxplayers == "" {
|
||||||
m.all_servers_store.Set(iter, 0, gtk.NewImage().RenderIcon(gtk.STOCK_NO, gtk.ICON_SIZE_SMALL_TOOLBAR, "").GPixbuf)
|
m.all_servers_store.Set(iter, 0, gtk.NewImage().RenderIcon(gtk.STOCK_NO, gtk.ICON_SIZE_SMALL_TOOLBAR, "").GPixbuf)
|
||||||
|
m.all_servers_store.SetValue(iter, 7, server.Server.Ip + ":" + server.Server.Port)
|
||||||
} else {
|
} else {
|
||||||
m.all_servers_store.Set(iter, 0, gtk.NewImage().RenderIcon(gtk.STOCK_OK, gtk.ICON_SIZE_SMALL_TOOLBAR, "").GPixbuf)
|
m.all_servers_store.Set(iter, 0, gtk.NewImage().RenderIcon(gtk.STOCK_OK, gtk.ICON_SIZE_SMALL_TOOLBAR, "").GPixbuf)
|
||||||
}
|
|
||||||
server_name := ctx.Colorizer.Fix(server.Server.Name)
|
server_name := ctx.Colorizer.Fix(server.Server.Name)
|
||||||
m.all_servers_store.SetValue(iter, 1, server_name)
|
m.all_servers_store.SetValue(iter, 1, server_name)
|
||||||
m.all_servers_store.SetValue(iter, 2, m.gamemodes[server.Server.Gamemode])
|
m.all_servers_store.SetValue(iter, 2, m.gamemodes[server.Server.Gamemode])
|
||||||
@ -978,6 +986,7 @@ func (m *MainWindow) loadAllServers() {
|
|||||||
m.all_servers_store.SetValue(iter, 7, server.Server.Ip + ":" + server.Server.Port)
|
m.all_servers_store.SetValue(iter, 7, server.Server.Ip + ":" + server.Server.Port)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func (m *MainWindow) loadFavoriteServers() {
|
func (m *MainWindow) loadFavoriteServers() {
|
||||||
fmt.Println("Loading favorite servers...")
|
fmt.Println("Loading favorite servers...")
|
||||||
@ -985,23 +994,32 @@ func (m *MainWindow) loadFavoriteServers() {
|
|||||||
if server.Server.Favorite != "1" {
|
if server.Server.Favorite != "1" {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if m.fav_servers_hide_offline.GetActive() && server.Server.Name == "" && server.Server.Players == "" {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
iter := new(gtk.TreeIter)
|
iter := new(gtk.TreeIter)
|
||||||
|
|
||||||
if !server.FavServersIterSet {
|
if !server.FavServersIterSet {
|
||||||
server.FavServersIter = iter
|
server.FavServersIter = iter
|
||||||
m.fav_servers_store.Append(iter)
|
|
||||||
server.FavServersIterSet = true
|
server.FavServersIterSet = true
|
||||||
} else {
|
} else {
|
||||||
iter = server.FavServersIter
|
iter = server.FavServersIter
|
||||||
}
|
}
|
||||||
if m.fav_servers_store.IterIsValid(iter) {
|
|
||||||
|
if !server.FavServersIterInList {
|
||||||
|
m.fav_servers_store.Append(iter)
|
||||||
|
server.FavServersIterInList = true
|
||||||
|
}
|
||||||
|
|
||||||
|
if m.fav_servers_hide_offline.GetActive() && server.Server.Players == "" && server.Server.Maxplayers == "" {
|
||||||
|
m.fav_servers_store.Remove(iter)
|
||||||
|
server.FavServersIterInList = false
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
if server.Server.Name == "" && server.Server.Players == "" {
|
if server.Server.Name == "" && server.Server.Players == "" {
|
||||||
m.fav_servers_store.Set(iter, 0, gtk.NewImage().RenderIcon(gtk.STOCK_NO, gtk.ICON_SIZE_SMALL_TOOLBAR, "").GPixbuf)
|
m.fav_servers_store.Set(iter, 0, gtk.NewImage().RenderIcon(gtk.STOCK_NO, gtk.ICON_SIZE_SMALL_TOOLBAR, "").GPixbuf)
|
||||||
|
m.fav_servers_store.SetValue(iter, 7, server.Server.Ip + ":" + server.Server.Port)
|
||||||
} else {
|
} else {
|
||||||
m.fav_servers_store.Set(iter, 0, gtk.NewImage().RenderIcon(gtk.STOCK_OK, gtk.ICON_SIZE_SMALL_TOOLBAR, "").GPixbuf)
|
m.fav_servers_store.Set(iter, 0, gtk.NewImage().RenderIcon(gtk.STOCK_OK, gtk.ICON_SIZE_SMALL_TOOLBAR, "").GPixbuf)
|
||||||
}
|
|
||||||
server_name := ctx.Colorizer.Fix(server.Server.Name)
|
server_name := ctx.Colorizer.Fix(server.Server.Name)
|
||||||
m.fav_servers_store.SetValue(iter, 1, server_name)
|
m.fav_servers_store.SetValue(iter, 1, server_name)
|
||||||
m.fav_servers_store.SetValue(iter, 2, m.gamemodes[server.Server.Gamemode])
|
m.fav_servers_store.SetValue(iter, 2, m.gamemodes[server.Server.Gamemode])
|
||||||
@ -1010,8 +1028,6 @@ func (m *MainWindow) loadFavoriteServers() {
|
|||||||
m.fav_servers_store.SetValue(iter, 5, server.Server.Ping)
|
m.fav_servers_store.SetValue(iter, 5, server.Server.Ping)
|
||||||
m.fav_servers_store.SetValue(iter, 6, server.Server.Version)
|
m.fav_servers_store.SetValue(iter, 6, server.Server.Version)
|
||||||
m.fav_servers_store.SetValue(iter, 7, server.Server.Ip + ":" + server.Server.Port)
|
m.fav_servers_store.SetValue(iter, 7, server.Server.Ip + ":" + server.Server.Port)
|
||||||
} else {
|
|
||||||
fmt.Println("Invalid iter for server: " + server.Server.Ip + ":" + server.Server.Port)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user