Filtering by game mode implemented.
This commit is contained in:
parent
f0ddda1af5
commit
979de8d858
@ -64,12 +64,16 @@ type MainWindow struct {
|
||||
all_servers_hide_private *gtk.CheckButton
|
||||
// Combobox for filtering server's versions.
|
||||
all_servers_version *gtk.ComboBoxText
|
||||
// Combobox for filtering by gamemode.
|
||||
all_servers_gamemode *gtk.ComboBoxText
|
||||
// Checkbox for hiding/showing offline servers in 'Favorites' tab list.
|
||||
fav_servers_hide_offline *gtk.CheckButton
|
||||
// Checkbox for hiding/showing passworded servers in 'Favorites' tab list.
|
||||
fav_servers_hide_private *gtk.CheckButton
|
||||
// Combobox for filtering server's versions.
|
||||
fav_servers_version *gtk.ComboBoxText
|
||||
// Combobox for filtering by gamemode.
|
||||
fav_servers_gamemode *gtk.ComboBoxText
|
||||
// Game launch button.
|
||||
launch_button *gtk.Button
|
||||
// Server's main information.
|
||||
@ -177,6 +181,11 @@ func (m *MainWindow) addToFavorites() {
|
||||
}
|
||||
}
|
||||
|
||||
func (m *MainWindow) allServersGamemodeFilterChanged() {
|
||||
ctx.Cfg.Cfg["/serverslist/all_servers/gamemode"] = strconv.Itoa(m.all_servers_gamemode.GetActive())
|
||||
ctx.Eventer.LaunchEvent("loadAllServers", nil)
|
||||
}
|
||||
|
||||
func (m *MainWindow) allServersVersionFilterChanged() {
|
||||
ctx.Cfg.Cfg["/serverslist/all_servers/version"] = strconv.Itoa(m.all_servers_version.GetActive())
|
||||
ctx.Eventer.LaunchEvent("loadAllServers", nil)
|
||||
@ -323,8 +332,13 @@ func (m *MainWindow) editFavorite() {
|
||||
}
|
||||
}
|
||||
|
||||
func (m *MainWindow) favServersGamemodeFilterChanged() {
|
||||
ctx.Cfg.Cfg["/serverslist/favorite/gamemode"] = strconv.Itoa(m.fav_servers_gamemode.GetActive())
|
||||
ctx.Eventer.LaunchEvent("loadFavoriteServers", nil)
|
||||
}
|
||||
|
||||
func (m *MainWindow) favServersVersionFilterChanged() {
|
||||
ctx.Cfg.Cfg["/serverslist/favorite/version"] = strconv.Itoa(m.all_servers_version.GetActive())
|
||||
ctx.Cfg.Cfg["/serverslist/favorite/version"] = strconv.Itoa(m.fav_servers_version.GetActive())
|
||||
ctx.Eventer.LaunchEvent("loadFavoriteServers", nil)
|
||||
}
|
||||
|
||||
@ -409,7 +423,18 @@ func (m *MainWindow) loadAllServers(data map[string]string) {
|
||||
|
||||
// Hide servers that using different version than selected in
|
||||
// filter?
|
||||
if m.all_servers_version.GetActiveText() != "All" && m.all_servers_version.GetActiveText() != server.Server.Version {
|
||||
if m.all_servers_version.GetActiveText() != "All versions" && m.all_servers_version.GetActiveText() != server.Server.Version {
|
||||
if server.AllServersIterInList && server.AllServersIterSet {
|
||||
m.all_servers_store.Remove(iter)
|
||||
server.AllServersIterInList = false
|
||||
}
|
||||
continue
|
||||
}
|
||||
|
||||
// Hide servers that using different gamemode than selected in
|
||||
// filter?
|
||||
gm_int_as_str := strconv.Itoa(m.all_servers_gamemode.GetActive())
|
||||
if m.all_servers_gamemode.GetActiveText() != "All gamemodes" && gm_int_as_str != server.Server.Gamemode {
|
||||
if server.AllServersIterInList && server.AllServersIterSet {
|
||||
m.all_servers_store.Remove(iter)
|
||||
server.AllServersIterInList = false
|
||||
@ -481,7 +506,18 @@ func (m *MainWindow) loadFavoriteServers(data map[string]string) {
|
||||
|
||||
// Hide servers that using different version than selected in
|
||||
// filter?
|
||||
if m.fav_servers_version.GetActiveText() != "All" && m.fav_servers_version.GetActiveText() != server.Server.Version {
|
||||
if m.fav_servers_version.GetActiveText() != "All versions" && m.fav_servers_version.GetActiveText() != server.Server.Version {
|
||||
if server.FavServersIterInList && server.FavServersIterSet {
|
||||
m.fav_servers_store.Remove(iter)
|
||||
server.FavServersIterInList = false
|
||||
}
|
||||
continue
|
||||
}
|
||||
|
||||
// Hide servers that using different gamemode than selected in
|
||||
// filter?
|
||||
gm_int_as_str := strconv.Itoa(m.fav_servers_gamemode.GetActive())
|
||||
if m.fav_servers_gamemode.GetActiveText() != "All gamemodes" && gm_int_as_str != server.Server.Gamemode {
|
||||
if server.FavServersIterInList && server.FavServersIterSet {
|
||||
m.fav_servers_store.Remove(iter)
|
||||
server.FavServersIterInList = false
|
||||
|
@ -5,6 +5,7 @@ import (
|
||||
"encoding/base64"
|
||||
"fmt"
|
||||
"runtime"
|
||||
"sort"
|
||||
"strconv"
|
||||
|
||||
// local
|
||||
@ -525,6 +526,7 @@ func (m *MainWindow) InitializeTabs() {
|
||||
}
|
||||
}
|
||||
|
||||
// Filtering by version.
|
||||
m.all_servers_version = gtk.NewComboBoxText()
|
||||
m.all_servers_version.SetTooltipText("Show only servers which uses selected version of Urban Terror")
|
||||
m.all_servers_version.AppendText("All versions")
|
||||
@ -541,6 +543,30 @@ func (m *MainWindow) InitializeTabs() {
|
||||
m.all_servers_version.Connect("changed", m.allServersVersionFilterChanged)
|
||||
tab_all_srv_ctl_vbox.PackStart(m.all_servers_version, false, true, 5)
|
||||
|
||||
// Filtering by gamemode
|
||||
m.all_servers_gamemode = gtk.NewComboBoxText()
|
||||
m.all_servers_gamemode.SetTooltipText("Show only servers which uses selected game mode")
|
||||
m.all_servers_gamemode.AppendText("All gamemodes")
|
||||
// Get sorted gamemodes keys.
|
||||
gm_keys := make([]int, 0, len(m.gamemodes))
|
||||
for i := range m.gamemodes {
|
||||
key, _ := strconv.Atoi(i)
|
||||
gm_keys = append(gm_keys, key)
|
||||
}
|
||||
sort.Ints(gm_keys)
|
||||
for i := range gm_keys {
|
||||
m.all_servers_gamemode.AppendText(m.gamemodes[strconv.Itoa(gm_keys[i])])
|
||||
}
|
||||
all_servers_gamemode_val, ok := ctx.Cfg.Cfg["/serverslist/all_servers/gamemode"]
|
||||
if ok {
|
||||
all_servers_gamemode_int, _ := strconv.Atoi(all_servers_gamemode_val)
|
||||
m.all_servers_gamemode.SetActive(all_servers_gamemode_int)
|
||||
} else {
|
||||
m.all_servers_gamemode.SetActive(0)
|
||||
}
|
||||
m.all_servers_gamemode.Connect("changed", m.allServersGamemodeFilterChanged)
|
||||
tab_all_srv_ctl_vbox.PackStart(m.all_servers_gamemode, false, true, 5)
|
||||
|
||||
// Final separator.
|
||||
ctl_sep := gtk.NewVBox(false, 0)
|
||||
tab_all_srv_ctl_vbox.PackStart(ctl_sep, true, true, 5)
|
||||
@ -653,6 +679,25 @@ func (m *MainWindow) InitializeTabs() {
|
||||
m.fav_servers_version.Connect("changed", m.favServersVersionFilterChanged)
|
||||
tab_fav_srv_ctl_vbox.PackStart(m.fav_servers_version, false, true, 5)
|
||||
|
||||
// Filtering by gamemode
|
||||
m.fav_servers_gamemode = gtk.NewComboBoxText()
|
||||
m.fav_servers_gamemode.SetTooltipText("Show only servers which uses selected game mode")
|
||||
m.fav_servers_gamemode.AppendText("All gamemodes")
|
||||
// Gamemode keys already sorted while adding same filter to "Servers"
|
||||
// tab, so just re-use them.
|
||||
for i := range gm_keys {
|
||||
m.fav_servers_gamemode.AppendText(m.gamemodes[strconv.Itoa(gm_keys[i])])
|
||||
}
|
||||
fav_servers_gamemode_val, ok := ctx.Cfg.Cfg["/serverslist/favorite/gamemode"]
|
||||
if ok {
|
||||
fav_servers_gamemode_int, _ := strconv.Atoi(fav_servers_gamemode_val)
|
||||
m.fav_servers_gamemode.SetActive(fav_servers_gamemode_int)
|
||||
} else {
|
||||
m.fav_servers_gamemode.SetActive(0)
|
||||
}
|
||||
m.fav_servers_gamemode.Connect("changed", m.favServersGamemodeFilterChanged)
|
||||
tab_fav_srv_ctl_vbox.PackStart(m.fav_servers_gamemode, false, true, 5)
|
||||
|
||||
// Final separator.
|
||||
ctl_fav_sep := gtk.NewVBox(false, 0)
|
||||
tab_fav_srv_ctl_vbox.PackStart(ctl_fav_sep, true, true, 5)
|
||||
|
Reference in New Issue
Block a user