Compare commits
40 Commits
v0.1.0-bet
...
v0.1.1
| Author | SHA1 | Date | |
|---|---|---|---|
| e66875ffbe | |||
| 979de8d858 | |||
| f0ddda1af5 | |||
| bd344fee2e | |||
| 7950ab5a1f | |||
| 3b3aae16b0 | |||
| a57c878dad | |||
| 474821ba7b | |||
| f32cf4d1f6 | |||
| bd04870aa3 | |||
| 280c65f116 | |||
| 32c6297765 | |||
| 190f76eb82 | |||
| 5c295f08ab | |||
| 061bfcaeb9 | |||
| 5ca8299714 | |||
| 9c8aa1cc34 | |||
| 5fcbd8536c | |||
| fb7a471aec | |||
| 8c9d948a52 | |||
| 8b44d194b5 | |||
| 3b0a93e63a | |||
| b85ba0470c | |||
| f127fdc9f4 | |||
| 5ef54d943e | |||
| 9e6cdfc869 | |||
| bfd3f884b3 | |||
| 7e6b698c1c | |||
| 4516abb916 | |||
| e731653652 | |||
| e16d6fa878 | |||
| 89298d894b | |||
| 88b9b31f6a | |||
| 1fe49871f1 | |||
| 4f5bf90dbe | |||
| 25bebf87df | |||
| c4ed421106 | |||
| 0c0fcd5b24 | |||
| 4d466a9d2b | |||
| 2cdee94efe |
@@ -2,6 +2,8 @@
|
||||
|
||||
[](https://gitter.im/urtrator/Lobby?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
|
||||
|
||||
Chat on Matrix: #gitter_urtrator=2Flobby:matrix.org (Gitter bridge).
|
||||
|
||||

|
||||
|
||||
URTrator is a desktop application that should (eventually) replace
|
||||
@@ -25,6 +27,7 @@ the game.
|
||||
* Favorites servers.
|
||||
* Updating single server.
|
||||
* Showing information about servers (like in UrT Connector).
|
||||
* Clipboard monitoring.
|
||||
|
||||
Planning:
|
||||
|
||||
@@ -35,11 +38,15 @@ Planning:
|
||||
* All kinds of notifications.
|
||||
* Extended profile editor, so every profile could have own configuration
|
||||
files, etc.
|
||||
* Clipboard monitoring.
|
||||
* ...maybe more :)
|
||||
|
||||
# Installation
|
||||
|
||||
## Precautions
|
||||
|
||||
Due to Go's GC bugs, it is required to use devel version of Go
|
||||
compiler!
|
||||
|
||||
## Release
|
||||
|
||||
You don't need to install anything, thanks to Go's.
|
||||
|
||||
7
cache/cache_servers.go
vendored
7
cache/cache_servers.go
vendored
@@ -55,6 +55,7 @@ func (c *Cache) FlushServers(data map[string]string) {
|
||||
new_servers[mapping_item_name].Port = s.Server.Port
|
||||
new_servers[mapping_item_name].Name = s.Server.Name
|
||||
new_servers[mapping_item_name].Players = s.Server.Players
|
||||
new_servers[mapping_item_name].Bots = s.Server.Bots
|
||||
new_servers[mapping_item_name].Maxplayers = s.Server.Maxplayers
|
||||
new_servers[mapping_item_name].Ping = s.Server.Ping
|
||||
new_servers[mapping_item_name].Map = s.Server.Map
|
||||
@@ -71,6 +72,7 @@ func (c *Cache) FlushServers(data map[string]string) {
|
||||
cached_servers[mapping_item_name].Port = s.Server.Port
|
||||
cached_servers[mapping_item_name].Name = s.Server.Name
|
||||
cached_servers[mapping_item_name].Players = s.Server.Players
|
||||
cached_servers[mapping_item_name].Bots = s.Server.Bots
|
||||
cached_servers[mapping_item_name].Maxplayers = s.Server.Maxplayers
|
||||
cached_servers[mapping_item_name].Ping = s.Server.Ping
|
||||
cached_servers[mapping_item_name].Map = s.Server.Map
|
||||
@@ -90,12 +92,12 @@ func (c *Cache) FlushServers(data map[string]string) {
|
||||
fmt.Println("Adding new servers...")
|
||||
if len(new_servers) > 0 {
|
||||
for _, srv := range new_servers {
|
||||
tx.NamedExec("INSERT INTO servers (ip, port, name, ping, players, maxplayers, gamemode, map, version, extended_config, players_info, is_private, favorite, profile_to_use) VALUES (:ip, :port, :name, :ping, :players, :maxplayers, :gamemode, :map, :version, :extended_config, :players_info, :is_private, :favorite, :profile_to_use)", srv)
|
||||
tx.NamedExec("INSERT INTO servers (ip, port, name, ping, players, maxplayers, gamemode, map, version, extended_config, players_info, is_private, favorite, profile_to_use, bots) VALUES (:ip, :port, :name, :ping, :players, :maxplayers, :gamemode, :map, :version, :extended_config, :players_info, :is_private, :favorite, :profile_to_use, :bots)", srv)
|
||||
}
|
||||
}
|
||||
fmt.Println("Updating cached servers...")
|
||||
for _, srv := range cached_servers {
|
||||
_, err := tx.NamedExec("UPDATE servers SET name=:name, players=:players, maxplayers=:maxplayers, gamemode=:gamemode, map=:map, ping=:ping, version=:version, extended_config=:extended_config, favorite=:favorite, password=:password, players_info=:players_info, is_private=:is_private, profile_to_use=:profile_to_use WHERE ip=:ip AND port=:port", &srv)
|
||||
_, err := tx.NamedExec("UPDATE servers SET name=:name, players=:players, maxplayers=:maxplayers, gamemode=:gamemode, map=:map, ping=:ping, version=:version, extended_config=:extended_config, favorite=:favorite, password=:password, players_info=:players_info, is_private=:is_private, profile_to_use=:profile_to_use, bots=:bots WHERE ip=:ip AND port=:port", &srv)
|
||||
if err != nil {
|
||||
fmt.Println(err.Error())
|
||||
}
|
||||
@@ -125,6 +127,7 @@ func (c *Cache) LoadServers(data map[string]string) {
|
||||
c.Servers[key].Server.Ip = server.Ip
|
||||
c.Servers[key].Server.Port = server.Port
|
||||
c.Servers[key].Server.Players = server.Players
|
||||
c.Servers[key].Server.Bots = server.Bots
|
||||
c.Servers[key].Server.Maxplayers = server.Maxplayers
|
||||
c.Servers[key].Server.Ping = server.Ping
|
||||
c.Servers[key].Server.Gamemode = server.Gamemode
|
||||
|
||||
@@ -21,8 +21,28 @@ type Colorizer struct {
|
||||
colors map[string]string
|
||||
}
|
||||
|
||||
func (c *Colorizer) ClearFromMarkup(data string) string {
|
||||
var result string = ""
|
||||
|
||||
data = html.EscapeString(data)
|
||||
|
||||
data_splitted := strings.Split(data, ">")
|
||||
|
||||
if len(data_splitted) > 1 {
|
||||
for item := range data_splitted {
|
||||
if len(data_splitted[item]) > 0 {
|
||||
result += strings.Split(data_splitted[item], "<")[0]
|
||||
}
|
||||
}
|
||||
} else {
|
||||
result = data_splitted[0]
|
||||
}
|
||||
|
||||
return result
|
||||
}
|
||||
|
||||
func (c *Colorizer) Fix(data string) string {
|
||||
result := ""
|
||||
var result string = ""
|
||||
|
||||
data = html.EscapeString(data)
|
||||
|
||||
|
||||
@@ -10,5 +10,11 @@
|
||||
package common
|
||||
|
||||
const (
|
||||
URTRATOR_VERSION = "0.1-beta4"
|
||||
URTRATOR_VERSION = "0.1.1"
|
||||
)
|
||||
|
||||
// Self-named.
|
||||
var SUPPORTED_URT_VERSIONS []string = []string{
|
||||
"4.2.023",
|
||||
"4.3.1",
|
||||
}
|
||||
|
||||
@@ -48,6 +48,7 @@ func migrate_full(db *Database, version int) {
|
||||
if version == 6 {six_to_seven(db); version = 7}
|
||||
if version == 7 {seven_to_eight(db); version = 8}
|
||||
if version == 8 {eight_to_nine(db); version = 9}
|
||||
if version == 9 {nine_to_ten(db); version = 10}
|
||||
}
|
||||
|
||||
// Initial database structure.
|
||||
@@ -115,3 +116,10 @@ func eight_to_nine(db *Database) {
|
||||
db.Db.MustExec("ALTER TABLE servers ADD is_private VARCHAR(1) NOT NULL DEFAULT '0'")
|
||||
db.Db.MustExec("UPDATE database SET version=9")
|
||||
}
|
||||
|
||||
// Bots count.
|
||||
func nine_to_ten(db *Database) {
|
||||
fmt.Println("Upgrading database from 9 to 10...")
|
||||
db.Db.MustExec("ALTER TABLE servers ADD bots VARCHAR(2) NOT NULL DEFAULT '0'")
|
||||
db.Db.MustExec("UPDATE database SET version=10")
|
||||
}
|
||||
|
||||
@@ -18,6 +18,8 @@ type Server struct {
|
||||
Name string `db:"name"`
|
||||
// Current players count
|
||||
Players string `db:"players"`
|
||||
// Bots count
|
||||
Bots string `db:"bots"`
|
||||
// Maximum players
|
||||
Maxplayers string `db:"maxplayers"`
|
||||
// Ping
|
||||
|
||||
@@ -150,6 +150,9 @@ ln -s ../../../Framework .
|
||||
cd ../../../MacOS
|
||||
GDK_PIXBUF_MODULE_FILE="../lib/gdk-pixbuf-2.0/loaders.cache" GDK_PIXBUF_MODULEDIR="../lib/gdk-pixbuf-2.0/2.10.0/loaders/" GTK_EXE_PREFIX="../lib" GTK_PATH="../Framework" ./gdk-pixbuf-query-loaders > ../lib/gdk-pixbuf-2.0/2.10.0/loaders.cache
|
||||
|
||||
echo "Copying icon theme..."
|
||||
|
||||
|
||||
echo "Finishing..."
|
||||
|
||||
echo "URTrator is ready! Copy URTrator.app bundle to Applications and launch it!"
|
||||
|
||||
@@ -34,7 +34,7 @@ type Pooler struct {
|
||||
func (p *Pooler) Initialize() {
|
||||
fmt.Println("Initializing requester goroutine pooler...")
|
||||
// ToDo: figure out how to make this work nice.
|
||||
p.maxrequests = 100
|
||||
p.maxrequests = 200
|
||||
_ = runtime.GOMAXPROCS(runtime.NumCPU() * 4)
|
||||
p.pp = "\377\377\377\377"
|
||||
fmt.Println("Pooler initialized")
|
||||
@@ -234,11 +234,34 @@ func (p *Pooler) UpdateSpecificServer(server *datamodels.Server) error {
|
||||
if len(received_lines) >= 2 {
|
||||
// Here we go, players information.
|
||||
players := received_lines[2:]
|
||||
var real_players int = 0
|
||||
var bots int = 0
|
||||
// Calculate players!
|
||||
if len(players) == 1 && len(players[0]) > 255 {
|
||||
server.Players = "0"
|
||||
server.Bots = "0"
|
||||
} else {
|
||||
server.Players = strconv.Itoa(len(players))
|
||||
// Looks like we have last element to be empty, due to
|
||||
// strings.Split() call before.
|
||||
for i := range players {
|
||||
// Get slice with data for bots-humans parsing.
|
||||
player_data := strings.Split(string(players[i]), " ")
|
||||
// If slice length isn't equal 3 - this is not what
|
||||
// we want.
|
||||
if len(player_data) != 3 {
|
||||
continue
|
||||
}
|
||||
|
||||
if player_data[1] == "0" {
|
||||
bots++
|
||||
} else {
|
||||
real_players++
|
||||
}
|
||||
}
|
||||
//server.Players = strconv.Itoa(len(players) - 1)
|
||||
server.Players = strconv.Itoa(real_players)
|
||||
server.Bots = strconv.Itoa(bots)
|
||||
fmt.Println(server.Players, server.Bots)
|
||||
}
|
||||
server.PlayersInfo = strings.Join(received_lines[2:], "\\")
|
||||
}
|
||||
|
||||
@@ -118,7 +118,6 @@ func (f *FavoriteDialog) initializeWindow() {
|
||||
f.window.SetModal(true)
|
||||
f.window.SetSizeRequest(400, 200)
|
||||
f.window.SetResizable(false)
|
||||
f.vbox = gtk.NewVBox(false, 0)
|
||||
|
||||
// Load program icon from base64.
|
||||
icon_bytes, _ := base64.StdEncoding.DecodeString(common.Logo)
|
||||
@@ -132,25 +131,27 @@ func (f *FavoriteDialog) initializeWindow() {
|
||||
gtk_opts := gtk_opts_raw.ToGObject()
|
||||
gtk_opts.Set("gtk-button-images", true)
|
||||
|
||||
f.vbox = gtk.NewVBox(false, 0)
|
||||
|
||||
table := gtk.NewTable(5, 2, false)
|
||||
f.vbox.PackStart(table, true, true, 5)
|
||||
|
||||
// Server name.
|
||||
srv_name_hbox := gtk.NewHBox(false, 0)
|
||||
f.vbox.PackStart(srv_name_hbox, false, true, 5)
|
||||
srv_name_label := gtk.NewLabel("Server name:")
|
||||
srv_name_hbox.PackStart(srv_name_label, false, true, 5)
|
||||
srv_name_sep := gtk.NewHSeparator()
|
||||
srv_name_hbox.PackStart(srv_name_sep, true, true, 5)
|
||||
srv_name_label.SetAlignment(0, 0)
|
||||
table.Attach(srv_name_label, 0, 1, 0, 1, gtk.FILL, gtk.SHRINK, 5, 5)
|
||||
|
||||
f.server_name = gtk.NewEntry()
|
||||
srv_name_hbox.PackStart(f.server_name, true, true, 5)
|
||||
table.Attach(f.server_name, 1, 2, 0, 1, gtk.FILL, gtk.FILL, 5, 5)
|
||||
|
||||
// Server address.
|
||||
srv_addr_hbox := gtk.NewHBox(false, 0)
|
||||
f.vbox.PackStart(srv_addr_hbox, false, true, 5)
|
||||
srv_addr_label := gtk.NewLabel("Server address:")
|
||||
srv_addr_hbox.PackStart(srv_addr_label, false, true, 5)
|
||||
srv_addr_sep := gtk.NewHSeparator()
|
||||
srv_addr_hbox.PackStart(srv_addr_sep, true, true, 5)
|
||||
srv_addr_label.SetAlignment(0, 0)
|
||||
table.Attach(srv_addr_label, 0, 1, 1, 2, gtk.FILL, gtk.SHRINK, 5, 5)
|
||||
|
||||
srv_addr_hbox := gtk.NewHBox(false, 0)
|
||||
f.server_address = gtk.NewEntry()
|
||||
srv_addr_hbox.PackStart(f.server_address, true, true, 5)
|
||||
srv_addr_hbox.PackStart(f.server_address, true, true, 0)
|
||||
srv_addr_update_btn := gtk.NewButton()
|
||||
srv_addr_update_btn.SetTooltipText("Update server information")
|
||||
srv_addr_update_btn_image := gtk.NewImageFromStock(gtk.STOCK_REDO, gtk.ICON_SIZE_SMALL_TOOLBAR)
|
||||
@@ -160,26 +161,29 @@ func (f *FavoriteDialog) initializeWindow() {
|
||||
if f.update {
|
||||
f.server_address.SetSensitive(false)
|
||||
}
|
||||
table.Attach(srv_addr_hbox, 1, 2, 1, 2, gtk.FILL, gtk.FILL, 5, 5)
|
||||
|
||||
// Server password.
|
||||
srv_pass_hbox := gtk.NewHBox(false, 0)
|
||||
f.vbox.PackStart(srv_pass_hbox, false, true, 5)
|
||||
srv_pass_label := gtk.NewLabel("Password:")
|
||||
srv_pass_hbox.PackStart(srv_pass_label, false, true, 5)
|
||||
srv_pass_sep := gtk.NewHSeparator()
|
||||
srv_pass_hbox.PackStart(srv_pass_sep, true, true, 5)
|
||||
srv_pass_label.SetAlignment(0, 0)
|
||||
table.Attach(srv_pass_label, 0, 1, 2, 3, gtk.FILL, gtk.SHRINK, 5, 5)
|
||||
|
||||
f.server_password = gtk.NewEntry()
|
||||
srv_pass_hbox.PackStart(f.server_password, true, true, 5)
|
||||
table.Attach(f.server_password, 1, 2, 2, 3, gtk.FILL, gtk.FILL, 5, 5)
|
||||
|
||||
// Profile to use.
|
||||
profile_hbox := gtk.NewHBox(false, 0)
|
||||
f.vbox.PackStart(profile_hbox, false, true, 5)
|
||||
profile_label := gtk.NewLabel("Profile:")
|
||||
profile_hbox.PackStart(profile_label, false, true, 5)
|
||||
profile_sep := gtk.NewHSeparator()
|
||||
profile_hbox.PackStart(profile_sep, true, true, 5)
|
||||
profile_label.SetAlignment(0, 0)
|
||||
table.Attach(profile_label, 0, 1, 3, 4, gtk.FILL, gtk.SHRINK, 5, 5)
|
||||
|
||||
f.profile = gtk.NewComboBoxText()
|
||||
profile_hbox.PackStart(f.profile, false, true, 5)
|
||||
table.Attach(f.profile , 1, 2, 3, 4, gtk.FILL, gtk.FILL, 5, 5)
|
||||
|
||||
// Invisible thing.
|
||||
inv_label1 := gtk.NewLabel("")
|
||||
table.Attach(inv_label1, 0, 1, 4, 5, gtk.EXPAND, gtk.FILL, 5, 5)
|
||||
inv_label2 := gtk.NewLabel("")
|
||||
table.Attach(inv_label2, 1, 2, 4, 5, gtk.EXPAND, gtk.FILL, 5, 5)
|
||||
|
||||
// Buttons hbox.
|
||||
buttons_hbox := gtk.NewHBox(false, 0)
|
||||
|
||||
246
ui/mainwindow.go
246
ui/mainwindow.go
@@ -13,6 +13,7 @@ import (
|
||||
// stdlib
|
||||
"fmt"
|
||||
"runtime"
|
||||
"sort"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
@@ -59,12 +60,26 @@ type MainWindow struct {
|
||||
profiles *gtk.ComboBoxText
|
||||
// Checkbox for hiding/showing offline servers in 'Servers' tab list.
|
||||
all_servers_hide_offline *gtk.CheckButton
|
||||
// Checkbox for hiding/showing passworded servers in 'Servers' tab list.
|
||||
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 information.
|
||||
// Server's main information.
|
||||
server_info *gtk.TreeView
|
||||
// Players information.
|
||||
players_info *gtk.TreeView
|
||||
// Quick connect: server address
|
||||
qc_server_address *gtk.Entry
|
||||
// Quick connect: password
|
||||
@@ -87,9 +102,12 @@ type MainWindow struct {
|
||||
fav_servers_store *gtk.ListStore
|
||||
// Server's information store.
|
||||
server_info_store *gtk.ListStore
|
||||
// Players information store.
|
||||
players_info_store *gtk.ListStore
|
||||
|
||||
// Dialogs.
|
||||
options_dialog *OptionsDialog
|
||||
server_cvars_dialog *ServerCVarsDialog
|
||||
|
||||
// Other
|
||||
// Old profiles count.
|
||||
@@ -127,8 +145,14 @@ type MainWindow struct {
|
||||
|
||||
|
||||
// Flags.
|
||||
// Application is initialized?
|
||||
initialized bool
|
||||
// Window is hidden?
|
||||
hidden bool
|
||||
// Use other's tab information?
|
||||
// Used when user changed active tab, to show information about
|
||||
// server which is selected on activated tab.
|
||||
use_other_servers_tab bool
|
||||
}
|
||||
|
||||
func (m *MainWindow) addToFavorites() {
|
||||
@@ -157,6 +181,16 @@ 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)
|
||||
}
|
||||
|
||||
// Executes when delimiter for two panes is moved, to calculate VALID
|
||||
// position.
|
||||
func (m *MainWindow) checkMainPanePosition() {
|
||||
@@ -298,6 +332,16 @@ 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.fav_servers_version.GetActive())
|
||||
ctx.Eventer.LaunchEvent("loadFavoriteServers", nil)
|
||||
}
|
||||
|
||||
// Executes when "Hide offline servers" checkbox changed it's state on
|
||||
// "Servers" tab.
|
||||
func (m *MainWindow) hideOfflineAllServers() {
|
||||
@@ -310,6 +354,18 @@ func (m *MainWindow) hideOfflineAllServers() {
|
||||
ctx.Eventer.LaunchEvent("loadAllServers", map[string]string{})
|
||||
}
|
||||
|
||||
// Executes when "Hide passworded servers" checkbox changed it's state on
|
||||
// "Servers" tab.
|
||||
func (m *MainWindow) hidePrivateAllServers() {
|
||||
fmt.Println("(Un)Hiding private servers in 'Servers' tab...")
|
||||
if m.all_servers_hide_private.GetActive() {
|
||||
ctx.Cfg.Cfg["/serverslist/all_servers/hide_private"] = "1"
|
||||
} else {
|
||||
ctx.Cfg.Cfg["/serverslist/all_servers/hide_private"] = "0"
|
||||
}
|
||||
ctx.Eventer.LaunchEvent("loadAllServers", map[string]string{})
|
||||
}
|
||||
|
||||
// Executes when "Hide offline servers" checkbox changed it's state on
|
||||
// "Favorites" tab.
|
||||
func (m *MainWindow) hideOfflineFavoriteServers() {
|
||||
@@ -322,6 +378,18 @@ func (m *MainWindow) hideOfflineFavoriteServers() {
|
||||
ctx.Eventer.LaunchEvent("loadFavoriteServers", map[string]string{})
|
||||
}
|
||||
|
||||
// Executes when "Hide passworded servers" checkbox changed it's state on
|
||||
// "Favorites" tab.
|
||||
func (m *MainWindow) hidePrivateFavoriteServers() {
|
||||
fmt.Println("(Un)Hiding private servers in 'Favorite' tab...")
|
||||
if m.all_servers_hide_private.GetActive() {
|
||||
ctx.Cfg.Cfg["/serverslist/favorite/hide_private"] = "1"
|
||||
} else {
|
||||
ctx.Cfg.Cfg["/serverslist/favorite/hide_private"] = "0"
|
||||
}
|
||||
ctx.Eventer.LaunchEvent("loadFavoriteServers", map[string]string{})
|
||||
}
|
||||
|
||||
func (m *MainWindow) loadAllServers(data map[string]string) {
|
||||
fmt.Println("Loading all servers...")
|
||||
for _, server := range ctx.Cache.Servers {
|
||||
@@ -335,6 +403,7 @@ func (m *MainWindow) loadAllServers(data map[string]string) {
|
||||
iter = server.AllServersIter
|
||||
}
|
||||
|
||||
// Hide offline servers?
|
||||
if m.all_servers_hide_offline.GetActive() && (server.Server.Players == "" && server.Server.Maxplayers == "" || ping > 9000) {
|
||||
if server.AllServersIterInList && server.AllServersIterSet {
|
||||
m.all_servers_store.Remove(iter)
|
||||
@@ -343,6 +412,36 @@ func (m *MainWindow) loadAllServers(data map[string]string) {
|
||||
continue
|
||||
}
|
||||
|
||||
// Hide private servers?
|
||||
if m.all_servers_hide_private.GetActive() && server.Server.IsPrivate == "1" {
|
||||
if server.AllServersIterInList && server.AllServersIterSet {
|
||||
m.all_servers_store.Remove(iter)
|
||||
server.AllServersIterInList = false
|
||||
}
|
||||
continue
|
||||
}
|
||||
|
||||
// Hide servers that using different version than selected in
|
||||
// filter?
|
||||
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
|
||||
}
|
||||
continue
|
||||
}
|
||||
|
||||
if !server.AllServersIterInList && server.AllServersIterSet {
|
||||
m.all_servers_store.Append(iter)
|
||||
server.AllServersIterInList = true
|
||||
@@ -366,7 +465,7 @@ func (m *MainWindow) loadAllServers(data map[string]string) {
|
||||
m.all_servers_store.SetValue(iter, m.column_pos["Servers"]["Name"], server_name)
|
||||
m.all_servers_store.SetValue(iter, m.column_pos["Servers"]["Mode"], m.getGameModeName(server.Server.Gamemode))
|
||||
m.all_servers_store.SetValue(iter, m.column_pos["Servers"]["Map"], server.Server.Map)
|
||||
m.all_servers_store.SetValue(iter, m.column_pos["Servers"]["Players"], server.Server.Players + "/" + server.Server.Maxplayers)
|
||||
m.all_servers_store.SetValue(iter, m.column_pos["Servers"]["Players"], server.Server.Players + "/" + server.Server.Bots + "/" + server.Server.Maxplayers)
|
||||
m.all_servers_store.SetValue(iter, m.column_pos["Servers"]["Ping"], server.Server.Ping)
|
||||
m.all_servers_store.SetValue(iter, m.column_pos["Servers"]["Version"], server.Server.Version)
|
||||
m.all_servers_store.SetValue(iter, m.column_pos["Servers"]["IP"], server.Server.Ip + ":" + server.Server.Port)
|
||||
@@ -387,6 +486,7 @@ func (m *MainWindow) loadFavoriteServers(data map[string]string) {
|
||||
iter = server.FavServersIter
|
||||
}
|
||||
|
||||
// Hide offline servers?
|
||||
if m.fav_servers_hide_offline.GetActive() && (server.Server.Players == "" && server.Server.Maxplayers == "" || ping > 9000) {
|
||||
if server.FavServersIterInList {
|
||||
m.fav_servers_store.Remove(iter)
|
||||
@@ -395,6 +495,36 @@ func (m *MainWindow) loadFavoriteServers(data map[string]string) {
|
||||
continue
|
||||
}
|
||||
|
||||
// Hide private servers?
|
||||
if m.fav_servers_hide_private.GetActive() && server.Server.IsPrivate == "1" {
|
||||
if server.FavServersIterInList && server.FavServersIterSet {
|
||||
m.fav_servers_store.Remove(iter)
|
||||
server.FavServersIterInList = false
|
||||
}
|
||||
continue
|
||||
}
|
||||
|
||||
// Hide servers that using different version than selected in
|
||||
// filter?
|
||||
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
|
||||
}
|
||||
continue
|
||||
}
|
||||
|
||||
// If server on favorites widget, but not favorited (e.g. just
|
||||
// removed from favorites) - remove it from list.
|
||||
if server.Server.Favorite != "1" && server.FavServersIterSet && server.FavServersIterInList {
|
||||
@@ -431,7 +561,7 @@ func (m *MainWindow) loadFavoriteServers(data map[string]string) {
|
||||
m.fav_servers_store.SetValue(iter, m.column_pos["Favorites"]["Name"], server_name)
|
||||
m.fav_servers_store.SetValue(iter, m.column_pos["Favorites"]["Mode"], m.getGameModeName(server.Server.Gamemode))
|
||||
m.fav_servers_store.SetValue(iter, m.column_pos["Favorites"]["Map"], server.Server.Map)
|
||||
m.fav_servers_store.SetValue(iter, m.column_pos["Favorites"]["Players"], server.Server.Players + "/" + server.Server.Maxplayers)
|
||||
m.fav_servers_store.SetValue(iter, m.column_pos["Favorites"]["Players"], server.Server.Players + "/" + server.Server.Bots + "/" + server.Server.Maxplayers)
|
||||
m.fav_servers_store.SetValue(iter, m.column_pos["Favorites"]["Ping"], server.Server.Ping)
|
||||
m.fav_servers_store.SetValue(iter, m.column_pos["Favorites"]["Version"], server.Server.Version)
|
||||
m.fav_servers_store.SetValue(iter, m.column_pos["Favorites"]["IP"], server.Server.Ip + ":" + server.Server.Port)
|
||||
@@ -453,10 +583,40 @@ func (m *MainWindow) loadProfiles(data map[string]string) {
|
||||
|
||||
m.old_profiles_count = len(ctx.Cache.Profiles)
|
||||
fmt.Println("Added " + strconv.Itoa(m.old_profiles_count) + " profiles")
|
||||
|
||||
m.profiles.SetActive(0)
|
||||
}
|
||||
|
||||
func (m *MainWindow) tabChanged() {
|
||||
if !m.initialized {
|
||||
return
|
||||
}
|
||||
|
||||
fmt.Println("Active tab changed...")
|
||||
current_tab := m.tab_widget.GetTabLabelText(m.tab_widget.GetNthPage(m.tab_widget.GetCurrentPage()))
|
||||
fmt.Println(current_tab)
|
||||
|
||||
m.use_other_servers_tab = true
|
||||
if strings.Contains(current_tab, "Servers") {
|
||||
m.fav_servers.Emit("cursor-changed")
|
||||
} else if strings.Contains(current_tab, "Favorites") {
|
||||
m.all_servers.Emit("cursor-changed")
|
||||
}
|
||||
m.use_other_servers_tab = false
|
||||
}
|
||||
|
||||
func (m *MainWindow) serversUpdateCompleted(data map[string]string) {
|
||||
ctx.Eventer.LaunchEvent("setToolbarLabelText", map[string]string{"text": "Servers updated."})
|
||||
// Trigger "selection-changed" events on currently active tab's
|
||||
// servers list.
|
||||
current_tab := m.tab_widget.GetTabLabelText(m.tab_widget.GetNthPage(m.tab_widget.GetCurrentPage()))
|
||||
|
||||
if strings.Contains(current_tab, "Servers") {
|
||||
m.all_servers.Emit("cursor-changed")
|
||||
} else if strings.Contains(current_tab, "Favorites") {
|
||||
m.fav_servers.Emit("cursor-changed")
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func (m *MainWindow) setQuickConnectDetails(data map[string]string) {
|
||||
@@ -487,14 +647,33 @@ func (m *MainWindow) showHide() {
|
||||
}
|
||||
}
|
||||
|
||||
func (m *MainWindow) showServerInformation() {
|
||||
fmt.Println("Showing server's information...")
|
||||
func (m *MainWindow) showServerCVars() {
|
||||
current_tab := m.tab_widget.GetTabLabelText(m.tab_widget.GetNthPage(m.tab_widget.GetCurrentPage()))
|
||||
if m.use_other_servers_tab {
|
||||
if strings.Contains(current_tab, "Servers") {
|
||||
current_tab = "Favorites"
|
||||
} else if strings.Contains(current_tab, "Favorites") {
|
||||
current_tab = "Servers"
|
||||
}
|
||||
}
|
||||
srv_address := m.getIpFromServersList(current_tab)
|
||||
if len(srv_address) > 0 {
|
||||
m.server_cvars_dialog.Initialize(m.window, srv_address)
|
||||
}
|
||||
}
|
||||
|
||||
func (m *MainWindow) showShortServerInformation() {
|
||||
fmt.Println("Server selection changed, updating server's information widget...")
|
||||
m.server_info_store.Clear()
|
||||
m.players_info_store.Clear()
|
||||
current_tab := m.tab_widget.GetTabLabelText(m.tab_widget.GetNthPage(m.tab_widget.GetCurrentPage()))
|
||||
if m.use_other_servers_tab {
|
||||
if strings.Contains(current_tab, "Servers") {
|
||||
current_tab = "Favorites"
|
||||
} else if strings.Contains(current_tab, "Favorites") {
|
||||
current_tab = "Servers"
|
||||
}
|
||||
}
|
||||
srv_address := m.getIpFromServersList(current_tab)
|
||||
|
||||
// Getting server information from cache.
|
||||
@@ -505,12 +684,8 @@ func (m *MainWindow) showShortServerInformation() {
|
||||
// Append to treeview generic info first. After appending it
|
||||
// will be deleted from map.
|
||||
|
||||
iter := new(gtk.TreeIter)
|
||||
m.server_info_store.Append(iter)
|
||||
m.server_info_store.SetValue(iter, 0, "<markup><span font_weight=\"bold\">GENERAL INFO</span></markup>")
|
||||
|
||||
// Server's name.
|
||||
iter = new(gtk.TreeIter)
|
||||
iter := new(gtk.TreeIter)
|
||||
m.server_info_store.Append(iter)
|
||||
m.server_info_store.SetValue(iter, 0, "Server's name")
|
||||
m.server_info_store.SetValue(iter, 1, ctx.Colorizer.Fix(parsed_general_data["sv_hostname"]))
|
||||
@@ -527,7 +702,7 @@ func (m *MainWindow) showShortServerInformation() {
|
||||
iter = new(gtk.TreeIter)
|
||||
m.server_info_store.Append(iter)
|
||||
m.server_info_store.SetValue(iter, 0, "Players")
|
||||
m.server_info_store.SetValue(iter, 1, server_info.Players + " of " + parsed_general_data["sv_maxclients"])
|
||||
m.server_info_store.SetValue(iter, 1, server_info.Players + " of " + parsed_general_data["sv_maxclients"] + " (" + server_info.Bots + " bots)")
|
||||
delete(parsed_general_data, "sv_maxclients")
|
||||
|
||||
// Ping
|
||||
@@ -558,23 +733,26 @@ func (m *MainWindow) showShortServerInformation() {
|
||||
}
|
||||
m.server_info_store.SetValue(iter, 1, passworded_status)
|
||||
|
||||
// Just a separator.
|
||||
iter = new(gtk.TreeIter)
|
||||
m.server_info_store.Append(iter)
|
||||
|
||||
// Players information
|
||||
iter = new(gtk.TreeIter)
|
||||
m.server_info_store.Append(iter)
|
||||
m.server_info_store.SetValue(iter, 0, "<markup><span font_weight=\"bold\">PLAYERS</span></markup>")
|
||||
|
||||
for _, value := range parsed_players_info {
|
||||
iter = new(gtk.TreeIter)
|
||||
nick := ctx.Colorizer.Fix(value["nick"])
|
||||
m.server_info_store.Append(iter)
|
||||
m.server_info_store.SetValue(iter, 0, nick)
|
||||
m.server_info_store.SetValue(iter, 1, "(frags: " + value["frags"] + " | ping: " + value["ping"] + ")")
|
||||
// Sorting keys of map.
|
||||
players_map_keys := make([]string, 0, len(parsed_players_info))
|
||||
for k := range parsed_players_info {
|
||||
// ToDo: figure out how to do this properly without
|
||||
// append().
|
||||
players_map_keys = append(players_map_keys, k)
|
||||
}
|
||||
|
||||
sort.Strings(players_map_keys)
|
||||
|
||||
for k := range players_map_keys {
|
||||
iter = new(gtk.TreeIter)
|
||||
nick := ctx.Colorizer.Fix(parsed_players_info[players_map_keys[k]]["nick"])
|
||||
m.players_info_store.Append(iter)
|
||||
m.players_info_store.SetValue(iter, 0, nick)
|
||||
m.players_info_store.SetValue(iter, 1, parsed_players_info[players_map_keys[k]]["frags"])
|
||||
m.players_info_store.SetValue(iter, 2, parsed_players_info[players_map_keys[k]]["ping"])
|
||||
}
|
||||
|
||||
/*
|
||||
// Just a separator.
|
||||
iter = new(gtk.TreeIter)
|
||||
m.server_info_store.Append(iter)
|
||||
@@ -584,12 +762,21 @@ func (m *MainWindow) showShortServerInformation() {
|
||||
m.server_info_store.Append(iter)
|
||||
m.server_info_store.SetValue(iter, 0, "<markup><span font_weight=\"bold\">OTHER PARAMETERS</span></markup>")
|
||||
|
||||
for key, value := range parsed_general_data {
|
||||
// Sort it!
|
||||
general_data_keys := make([]string, 0, len(parsed_general_data))
|
||||
for k := range parsed_general_data {
|
||||
general_data_keys = append(general_data_keys, k)
|
||||
}
|
||||
|
||||
sort.Strings(general_data_keys)
|
||||
|
||||
for k := range general_data_keys {
|
||||
iter = new(gtk.TreeIter)
|
||||
m.server_info_store.Append(iter)
|
||||
m.server_info_store.SetValue(iter, 0, key)
|
||||
m.server_info_store.SetValue(iter, 1, value)
|
||||
m.server_info_store.SetValue(iter, 0, general_data_keys[k])
|
||||
m.server_info_store.SetValue(iter, 1, parsed_general_data[general_data_keys[k]])
|
||||
}
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
||||
@@ -605,6 +792,7 @@ func (m *MainWindow) unlockInterface() {
|
||||
}
|
||||
|
||||
func (m *MainWindow) updateOneServer() {
|
||||
ctx.Eventer.LaunchEvent("setToolbarLabelText", map[string]string{"text": "<markup><span foreground=\"red\" font_weight=\"bold\">Updating selected server...</span></markup>"})
|
||||
current_tab := m.tab_widget.GetTabLabelText(m.tab_widget.GetNthPage(m.tab_widget.GetCurrentPage()))
|
||||
srv_address := m.getIpFromServersList(current_tab)
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@ import (
|
||||
"encoding/base64"
|
||||
"fmt"
|
||||
"runtime"
|
||||
"sort"
|
||||
"strconv"
|
||||
|
||||
// local
|
||||
@@ -84,6 +85,7 @@ func (m *MainWindow) Initialize() {
|
||||
|
||||
// Dialogs initialization.
|
||||
m.options_dialog = &OptionsDialog{}
|
||||
m.server_cvars_dialog = &ServerCVarsDialog{}
|
||||
|
||||
// Main menu.
|
||||
if runtime.GOOS == "darwin" {
|
||||
@@ -130,7 +132,7 @@ func (m *MainWindow) Initialize() {
|
||||
m.vbox.PackStart(profile_and_launch_hbox, false, true, 5)
|
||||
|
||||
// Separator
|
||||
sep := gtk.NewHSeparator()
|
||||
sep := gtk.NewHBox(false, 0)
|
||||
profile_and_launch_hbox.PackStart(sep, true, true, 5)
|
||||
|
||||
// Profile selection.
|
||||
@@ -149,12 +151,16 @@ func (m *MainWindow) Initialize() {
|
||||
m.launch_button = gtk.NewButtonWithLabel("Launch!")
|
||||
m.launch_button.SetTooltipText("Launch Urban Terror")
|
||||
m.launch_button.Clicked(m.launchGame)
|
||||
launch_button_image := gtk.NewImageFromPixbuf(logo.ScaleSimple(32, 32, gdkpixbuf.INTERP_NEAREST))
|
||||
launch_button_image := gtk.NewImageFromPixbuf(logo.ScaleSimple(24, 24, gdkpixbuf.INTERP_HYPER))
|
||||
m.launch_button.SetImage(launch_button_image)
|
||||
profile_and_launch_hbox.PackStart(m.launch_button, false, true, 5)
|
||||
|
||||
m.window.Add(m.vbox)
|
||||
|
||||
if runtime.GOOS == "darwin" {
|
||||
m.initializeMacAfter()
|
||||
}
|
||||
|
||||
m.window.ShowAll()
|
||||
|
||||
// Launch events.
|
||||
@@ -165,6 +171,9 @@ func (m *MainWindow) Initialize() {
|
||||
ctx.Eventer.LaunchEvent("loadFavoriteServers", map[string]string{})
|
||||
ctx.Eventer.LaunchEvent("setToolbarLabelText", map[string]string{"text": "URTrator is ready."})
|
||||
|
||||
// Set flag that shows to other parts that we're initialized.
|
||||
m.initialized = true
|
||||
|
||||
gtk.Main()
|
||||
}
|
||||
|
||||
@@ -236,6 +245,7 @@ func (m *MainWindow) initializeSidebar() {
|
||||
|
||||
// Scrolled thing.
|
||||
si_scroll := gtk.NewScrolledWindow(nil, nil)
|
||||
si_scroll.SetPolicy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
|
||||
si_vbox.PackStart(si_scroll, true, true, 5)
|
||||
|
||||
// Server's information.
|
||||
@@ -250,10 +260,32 @@ func (m *MainWindow) initializeSidebar() {
|
||||
|
||||
si_scroll.Add(m.server_info)
|
||||
|
||||
// Button to view additional server info.
|
||||
additional_srv_info_button := gtk.NewButtonWithLabel("Additional information")
|
||||
additional_srv_info_button.Clicked(m.showServerInformation)
|
||||
si_vbox.PackStart(additional_srv_info_button, false, true, 5)
|
||||
// Players information.
|
||||
players_info_frame := gtk.NewFrame("Players")
|
||||
sidebar_vbox.PackStart(players_info_frame, true, true, 5)
|
||||
|
||||
pi_scroll := gtk.NewScrolledWindow(nil, nil)
|
||||
pi_scroll.SetPolicy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
|
||||
players_info_frame.Add(pi_scroll)
|
||||
|
||||
m.players_info = gtk.NewTreeView()
|
||||
m.players_info.SetModel(m.players_info_store)
|
||||
pi_scroll.Add(m.players_info)
|
||||
|
||||
name_column := gtk.NewTreeViewColumnWithAttributes("Player name", gtk.NewCellRendererText(), "markup", 0)
|
||||
m.players_info.AppendColumn(name_column)
|
||||
|
||||
frags_column := gtk.NewTreeViewColumnWithAttributes("Frags", gtk.NewCellRendererText(), "markup", 1)
|
||||
m.players_info.AppendColumn(frags_column)
|
||||
|
||||
ping_column := gtk.NewTreeViewColumnWithAttributes("Ping", gtk.NewCellRendererText(), "markup", 2)
|
||||
m.players_info.AppendColumn(ping_column)
|
||||
|
||||
// Show CVars button.
|
||||
show_cvars_button := gtk.NewButtonWithLabel("Show CVars")
|
||||
show_cvars_button.SetTooltipText("Show server's CVars")
|
||||
show_cvars_button.Clicked(m.showServerCVars)
|
||||
sidebar_vbox.PackStart(show_cvars_button, false, true, 5)
|
||||
|
||||
// Quick connect frame.
|
||||
quick_connect_frame := gtk.NewFrame("Quick connect")
|
||||
@@ -296,6 +328,9 @@ func (m *MainWindow) initializeSidebar() {
|
||||
|
||||
// Initializes internal storages.
|
||||
func (m *MainWindow) initializeStorages() {
|
||||
// Application isn't initialized.
|
||||
m.initialized = false
|
||||
m.use_other_servers_tab = false
|
||||
// Gamemodes.
|
||||
m.gamemodes = make(map[string]string)
|
||||
m.gamemodes = map[string]string{
|
||||
@@ -346,6 +381,10 @@ func (m *MainWindow) initializeStorages() {
|
||||
// Server's information store. Used for quick preview in main window.
|
||||
m.server_info_store = gtk.NewListStore(glib.G_TYPE_STRING, glib.G_TYPE_STRING)
|
||||
|
||||
// Players information store. Used in sidebar for players list for
|
||||
// currently selected server.
|
||||
m.players_info_store = gtk.NewListStore(glib.G_TYPE_STRING, glib.G_TYPE_STRING, glib.G_TYPE_STRING)
|
||||
|
||||
// Profiles count after filling combobox. Defaulting to 0.
|
||||
m.old_profiles_count = 0
|
||||
|
||||
@@ -384,6 +423,7 @@ func (m *MainWindow) initializeStorages() {
|
||||
func (m *MainWindow) InitializeTabs() {
|
||||
// Create tabs widget.
|
||||
m.tab_widget = gtk.NewNotebook()
|
||||
m.tab_widget.Connect("switch-page", m.tabChanged)
|
||||
|
||||
tab_allsrv_hbox := gtk.NewHBox(false, 0)
|
||||
swin1 := gtk.NewScrolledWindow(nil, nil)
|
||||
@@ -439,9 +479,15 @@ func (m *MainWindow) InitializeTabs() {
|
||||
|
||||
// Sorting.
|
||||
// By default we are sorting by server name.
|
||||
// ToDo: remembering it to configuration storage.
|
||||
m.all_servers_store_sortable.SetSortColumnId(m.column_pos["Servers"]["Name"], gtk.SORT_ASCENDING)
|
||||
|
||||
// Sorting functions.
|
||||
// Race conditions and GC crazyness appears when activated, so for
|
||||
// now commenting it out.
|
||||
m.all_servers_store_sortable.SetSortFunc(m.column_pos["Servers"]["Name"], m.sortServersByName)
|
||||
m.all_servers_store_sortable.SetSortFunc(m.column_pos["Servers"]["Players"], m.sortServersByPlayers)
|
||||
m.all_servers_store_sortable.SetSortFunc(m.column_pos["Servers"]["Ping"], m.sortServersByPing)
|
||||
|
||||
// Selection changed signal, which will update server's short info pane.
|
||||
m.all_servers.Connect("cursor-changed", m.showShortServerInformation)
|
||||
|
||||
@@ -454,12 +500,75 @@ func (m *MainWindow) InitializeTabs() {
|
||||
m.all_servers_hide_offline.SetTooltipText("Hide offline servers on Servers tab")
|
||||
tab_all_srv_ctl_vbox.PackStart(m.all_servers_hide_offline, false, true, 5)
|
||||
m.all_servers_hide_offline.Clicked(m.hideOfflineAllServers)
|
||||
if ctx.Cfg.Cfg["/serverslist/all_servers/hide_offline"] == "1" {
|
||||
// Restore value of hide offline servers checkbox.
|
||||
// Set to checked for new installations.
|
||||
all_servers_hide_offline_cb_val, ok := ctx.Cfg.Cfg["/serverslist/all_servers/hide_offline"]
|
||||
if !ok {
|
||||
m.all_servers_hide_offline.SetActive(true)
|
||||
} else {
|
||||
if all_servers_hide_offline_cb_val == "1" {
|
||||
m.all_servers_hide_offline.SetActive(true)
|
||||
}
|
||||
}
|
||||
|
||||
// Checkbox for hiding passworded servers.
|
||||
m.all_servers_hide_private = gtk.NewCheckButtonWithLabel("Hide private servers")
|
||||
m.all_servers_hide_private.SetTooltipText("Hide servers which requires password to enter")
|
||||
tab_all_srv_ctl_vbox.PackStart(m.all_servers_hide_private, false, true, 5)
|
||||
m.all_servers_hide_private.Clicked(m.hidePrivateAllServers)
|
||||
// Restore checkbox value.
|
||||
all_servers_hide_private_cb_val, ok := ctx.Cfg.Cfg["/serverslist/all_servers/hide_private"]
|
||||
if !ok {
|
||||
m.all_servers_hide_private.SetActive(true)
|
||||
} else {
|
||||
if all_servers_hide_private_cb_val == "1" {
|
||||
m.all_servers_hide_private.SetActive(true)
|
||||
}
|
||||
}
|
||||
|
||||
// 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")
|
||||
for i := range common.SUPPORTED_URT_VERSIONS {
|
||||
m.all_servers_version.AppendText(common.SUPPORTED_URT_VERSIONS[i])
|
||||
}
|
||||
all_servers_version_val, ok := ctx.Cfg.Cfg["/serverslist/all_servers/version"]
|
||||
if ok {
|
||||
all_servers_version_int, _ := strconv.Atoi(all_servers_version_val)
|
||||
m.all_servers_version.SetActive(all_servers_version_int)
|
||||
} else {
|
||||
m.all_servers_version.SetActive(0)
|
||||
}
|
||||
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.NewVSeparator()
|
||||
ctl_sep := gtk.NewVBox(false, 0)
|
||||
tab_all_srv_ctl_vbox.PackStart(ctl_sep, true, true, 5)
|
||||
|
||||
// Favorites servers
|
||||
@@ -493,7 +602,11 @@ func (m *MainWindow) InitializeTabs() {
|
||||
width_int, _ := strconv.Atoi(width)
|
||||
|
||||
col := gtk.NewTreeViewColumnWithAttributes(name, gtk.NewCellRendererText(), "markup", position_int)
|
||||
// For some reason this cause panic on Windows, so disabling
|
||||
// default sorting here.
|
||||
if runtime.GOOS != "windows" {
|
||||
col.SetSortColumnId(position_int)
|
||||
}
|
||||
col.SetReorderable(true)
|
||||
col.SetResizable(true)
|
||||
// GtkTreeViewColumn.SetFixedWidth() accepts only positive integers.
|
||||
@@ -524,12 +637,69 @@ func (m *MainWindow) InitializeTabs() {
|
||||
m.fav_servers_hide_offline.SetTooltipText("Hide offline servers on Favorites tab")
|
||||
tab_fav_srv_ctl_vbox.PackStart(m.fav_servers_hide_offline, false, true, 5)
|
||||
m.fav_servers_hide_offline.Clicked(m.hideOfflineFavoriteServers)
|
||||
if ctx.Cfg.Cfg["/serverslist/favorite/hide_offline"] == "1" {
|
||||
// Restore value of hide offline servers checkbox.
|
||||
// Set to checked for new installations.
|
||||
favorite_servers_hide_offline_cb_val, ok := ctx.Cfg.Cfg["/serverslist/favorite/hide_offline"]
|
||||
if !ok {
|
||||
m.fav_servers_hide_offline.SetActive(true)
|
||||
} else {
|
||||
if favorite_servers_hide_offline_cb_val == "1" {
|
||||
m.fav_servers_hide_offline.SetActive(true)
|
||||
}
|
||||
}
|
||||
|
||||
// Checkbox for hiding passworded servers.
|
||||
m.fav_servers_hide_private = gtk.NewCheckButtonWithLabel("Hide private servers")
|
||||
m.fav_servers_hide_private.SetTooltipText("Hide servers which requires password to enter")
|
||||
tab_fav_srv_ctl_vbox.PackStart(m.fav_servers_hide_private, false, true, 5)
|
||||
m.fav_servers_hide_private.Clicked(m.hidePrivateFavoriteServers)
|
||||
// Restore checkbox value.
|
||||
fav_servers_hide_private_cb_val, ok := ctx.Cfg.Cfg["/serverslist/favorite/hide_private"]
|
||||
if !ok {
|
||||
m.fav_servers_hide_private.SetActive(true)
|
||||
} else {
|
||||
if fav_servers_hide_private_cb_val == "1" {
|
||||
m.fav_servers_hide_private.SetActive(true)
|
||||
}
|
||||
}
|
||||
|
||||
m.fav_servers_version = gtk.NewComboBoxText()
|
||||
m.fav_servers_version.SetTooltipText("Show only servers which uses selected version of Urban Terror")
|
||||
m.fav_servers_version.AppendText("All versions")
|
||||
for i := range common.SUPPORTED_URT_VERSIONS {
|
||||
m.fav_servers_version.AppendText(common.SUPPORTED_URT_VERSIONS[i])
|
||||
}
|
||||
fav_servers_version_val, ok := ctx.Cfg.Cfg["/serverslist/favorite/version"]
|
||||
if ok {
|
||||
fav_servers_version_int, _ := strconv.Atoi(fav_servers_version_val)
|
||||
m.fav_servers_version.SetActive(fav_servers_version_int)
|
||||
} else {
|
||||
m.fav_servers_version.SetActive(0)
|
||||
}
|
||||
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.NewVSeparator()
|
||||
ctl_fav_sep := gtk.NewVBox(false, 0)
|
||||
tab_fav_srv_ctl_vbox.PackStart(ctl_fav_sep, true, true, 5)
|
||||
|
||||
// Add tab_widget widget to window.
|
||||
@@ -548,7 +718,7 @@ func (m *MainWindow) InitializeToolbar() {
|
||||
button_update_all_servers_icon_pixbuf.Write(button_update_all_servers_icon_bytes)
|
||||
button_update_all_servers_icon := gtk.NewImageFromPixbuf(button_update_all_servers_icon_pixbuf.GetPixbuf())
|
||||
button_update_all_servers := gtk.NewToolButton(button_update_all_servers_icon, "Update all servers")
|
||||
button_update_all_servers.SetTooltipText("Update all servers in all tabs")
|
||||
button_update_all_servers.SetTooltipText("Update all servers in currently selected tab")
|
||||
button_update_all_servers.OnClicked(m.UpdateServers)
|
||||
m.toolbar.Insert(button_update_all_servers, 0)
|
||||
|
||||
@@ -572,7 +742,7 @@ func (m *MainWindow) InitializeToolbar() {
|
||||
fav_button_icon_pixbuf.SetSize(24, 24)
|
||||
fav_button_icon_pixbuf.Write(fav_button_icon_bytes)
|
||||
fav_button_icon := gtk.NewImageFromPixbuf(fav_button_icon_pixbuf.GetPixbuf())
|
||||
fav_button := gtk.NewToolButton(fav_button_icon, "Update all servers")
|
||||
fav_button := gtk.NewToolButton(fav_button_icon, "Add to favorites")
|
||||
fav_button.SetTooltipText("Add selected server to favorites")
|
||||
fav_button.OnClicked(m.addToFavorites)
|
||||
m.toolbar.Insert(fav_button, 3)
|
||||
|
||||
@@ -21,6 +21,10 @@ func (m *MainWindow) initializeMac() {
|
||||
}
|
||||
}
|
||||
|
||||
func (m *MainWindow) initializeMacAfter() {
|
||||
m.toolbar.SetStyle(gtk.TOOLBAR_ICONS)
|
||||
}
|
||||
|
||||
func (m *MainWindow) initializeMacMenu() {
|
||||
// This is a placeholder, in future we will use native mac menu.
|
||||
// For now it launches default menu initialization.
|
||||
|
||||
96
ui/mainwindow_servers_sorting.go
Normal file
96
ui/mainwindow_servers_sorting.go
Normal file
@@ -0,0 +1,96 @@
|
||||
package ui
|
||||
|
||||
import (
|
||||
// stdlib
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
// other
|
||||
"github.com/mattn/go-gtk/glib"
|
||||
"github.com/mattn/go-gtk/gtk"
|
||||
)
|
||||
|
||||
func (m *MainWindow) sortServersByName(model *gtk.TreeModel, a *gtk.TreeIter, b *gtk.TreeIter) int {
|
||||
var name1_raw glib.GValue
|
||||
var name2_raw glib.GValue
|
||||
|
||||
current_tab := m.tab_widget.GetTabLabelText(m.tab_widget.GetNthPage(m.tab_widget.GetCurrentPage()))
|
||||
if current_tab == "Servers" {
|
||||
model.GetValue(a, m.column_pos["Servers"]["Name"], &name1_raw)
|
||||
model.GetValue(b, m.column_pos["Servers"]["Name"], &name2_raw)
|
||||
} else if current_tab == "Favorites" {
|
||||
model.GetValue(a, m.column_pos["Favorites"]["Name"], &name1_raw)
|
||||
model.GetValue(b, m.column_pos["Favorites"]["Name"], &name2_raw)
|
||||
} else {
|
||||
return 0
|
||||
}
|
||||
|
||||
name1 := strings.ToLower(ctx.Colorizer.ClearFromMarkup(name1_raw.GetString()))
|
||||
name2 := strings.ToLower(ctx.Colorizer.ClearFromMarkup(name2_raw.GetString()))
|
||||
|
||||
if name1 < name2 {
|
||||
return -1
|
||||
} else {
|
||||
return 1
|
||||
}
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
func (m *MainWindow) sortServersByPlayers(model *gtk.TreeModel, a *gtk.TreeIter, b *gtk.TreeIter) int {
|
||||
var players1_raw glib.GValue
|
||||
var players2_raw glib.GValue
|
||||
|
||||
current_tab := m.tab_widget.GetTabLabelText(m.tab_widget.GetNthPage(m.tab_widget.GetCurrentPage()))
|
||||
if current_tab == "Servers" {
|
||||
model.GetValue(a, m.column_pos["Servers"]["Players"], &players1_raw)
|
||||
model.GetValue(b, m.column_pos["Servers"]["Players"], &players2_raw)
|
||||
} else if current_tab == "Favorites" {
|
||||
model.GetValue(a, m.column_pos["Favorites"]["Players"], &players1_raw)
|
||||
model.GetValue(b, m.column_pos["Favorites"]["Players"], &players2_raw)
|
||||
} else {
|
||||
return 0
|
||||
}
|
||||
|
||||
players1_online := strings.Split(players1_raw.GetString(), "/")[0]
|
||||
players2_online := strings.Split(players2_raw.GetString(), "/")[0]
|
||||
|
||||
if len(players1_online) > 0 && len(players2_online) > 0 {
|
||||
players1, _ := strconv.Atoi(players1_online)
|
||||
players2, _ := strconv.Atoi(players2_online)
|
||||
if players1 > players2 {
|
||||
return -1
|
||||
} else {
|
||||
return 1
|
||||
}
|
||||
}
|
||||
|
||||
return -1
|
||||
}
|
||||
|
||||
func (m *MainWindow) sortServersByPing(model *gtk.TreeModel, a *gtk.TreeIter, b *gtk.TreeIter) int {
|
||||
var ping1_raw glib.GValue
|
||||
var ping2_raw glib.GValue
|
||||
|
||||
current_tab := m.tab_widget.GetTabLabelText(m.tab_widget.GetNthPage(m.tab_widget.GetCurrentPage()))
|
||||
if current_tab == "Servers" {
|
||||
model.GetValue(a, m.column_pos["Servers"]["Ping"], &ping1_raw)
|
||||
model.GetValue(b, m.column_pos["Servers"]["Ping"], &ping2_raw)
|
||||
} else if current_tab == "Favorites" {
|
||||
model.GetValue(a, m.column_pos["Favorites"]["Ping"], &ping1_raw)
|
||||
model.GetValue(b, m.column_pos["Favorites"]["Ping"], &ping2_raw)
|
||||
} else {
|
||||
return 0
|
||||
}
|
||||
|
||||
ping1, _ := strconv.Atoi(ping1_raw.GetString())
|
||||
ping2, _ := strconv.Atoi(ping2_raw.GetString())
|
||||
|
||||
if ping1 < ping2 {
|
||||
return 1
|
||||
} else {
|
||||
return -1
|
||||
}
|
||||
|
||||
return -1
|
||||
}
|
||||
@@ -146,15 +146,33 @@ func (o *OptionsDialog) initializeAppearanceTab() {
|
||||
func (o *OptionsDialog) initializeGeneralTab() {
|
||||
general_vbox := gtk.NewVBox(false, 0)
|
||||
|
||||
general_table := gtk.NewTable(2, 2, false)
|
||||
|
||||
// Tray icon checkbox.
|
||||
o.show_tray_icon = gtk.NewCheckButtonWithLabel("Show tray icon?")
|
||||
show_tray_icon_label := gtk.NewLabel("Show icon in tray")
|
||||
show_tray_icon_label.SetAlignment(0, 0)
|
||||
general_table.Attach(show_tray_icon_label, 0, 1, 0, 1, gtk.FILL, gtk.SHRINK, 5, 5)
|
||||
|
||||
o.show_tray_icon = gtk.NewCheckButtonWithLabel("")
|
||||
o.show_tray_icon.SetTooltipText("Show icon in tray")
|
||||
general_vbox.PackStart(o.show_tray_icon, false, true, 5)
|
||||
general_table.Attach(o.show_tray_icon, 1, 2, 0, 1, gtk.FILL, gtk.FILL, 5, 5)
|
||||
|
||||
// Autoupdate checkbox.
|
||||
o.autoupdate = gtk.NewCheckButtonWithLabel("Automatically update URTrator?")
|
||||
o.autoupdate.SetTooltipText("Should URTrator check for updates and update itself? Not working now.")
|
||||
general_vbox.PackStart(o.autoupdate, false, true, 5)
|
||||
autoupdate_tooltip := "Should URTrator check for updates and update itself? Not working now."
|
||||
autoupdate_label := gtk.NewLabel("Automatically update URTrator?")
|
||||
autoupdate_label.SetTooltipText(autoupdate_tooltip)
|
||||
autoupdate_label.SetAlignment(0, 0)
|
||||
general_table.Attach(autoupdate_label, 0, 1, 1, 2, gtk.FILL, gtk.SHRINK, 5, 5)
|
||||
|
||||
o.autoupdate = gtk.NewCheckButtonWithLabel("")
|
||||
o.autoupdate.SetTooltipText(autoupdate_tooltip)
|
||||
general_table.Attach(o.autoupdate, 1, 2, 1, 2, gtk.FILL, gtk.FILL, 5, 5)
|
||||
|
||||
// Vertical separator.
|
||||
sep := gtk.NewVBox(false, 0)
|
||||
|
||||
general_vbox.PackStart(general_table, false, true, 0)
|
||||
general_vbox.PackStart(sep, false, true, 0)
|
||||
|
||||
o.tab_widget.AppendPage(general_vbox, gtk.NewLabel("General"))
|
||||
}
|
||||
@@ -176,7 +194,7 @@ func (o *OptionsDialog) initializeTabs() {
|
||||
|
||||
// Buttons for saving and discarding changes.
|
||||
buttons_hbox := gtk.NewHBox(false, 0)
|
||||
sep := gtk.NewHSeparator()
|
||||
sep := gtk.NewHBox(false, 0)
|
||||
|
||||
cancel_button := gtk.NewButtonWithLabel("Cancel")
|
||||
cancel_button.Clicked(o.closeOptionsDialogByCancel)
|
||||
@@ -195,7 +213,7 @@ func (o *OptionsDialog) initializeTabs() {
|
||||
}
|
||||
|
||||
func (o *OptionsDialog) initializeUrtTab() {
|
||||
urt_hbox := gtk.NewHBox(false, 0)
|
||||
urt_hbox := gtk.NewHBox(false, 5)
|
||||
|
||||
// Profiles list.
|
||||
o.profiles_list = gtk.NewTreeView()
|
||||
@@ -205,17 +223,13 @@ func (o *OptionsDialog) initializeUrtTab() {
|
||||
o.profiles_list.AppendColumn(gtk.NewTreeViewColumnWithAttributes("Profile name", gtk.NewCellRendererText(), "text", 0))
|
||||
o.profiles_list.AppendColumn(gtk.NewTreeViewColumnWithAttributes("Urban Terror version", gtk.NewCellRendererText(), "text", 1))
|
||||
|
||||
//crt := gtk.NewCellRendererToggle()
|
||||
//second_x_column := gtk.NewTreeViewColumnWithAttributes("Second X session", crt, "bool", 2)
|
||||
//o.profiles_list.AppendColumn(second_x_column)
|
||||
|
||||
// Profiles list buttons.
|
||||
urt_profiles_buttons_vbox := gtk.NewVBox(false, 0)
|
||||
|
||||
button_add := gtk.NewButtonWithLabel("Add")
|
||||
button_add.SetTooltipText("Add new profile")
|
||||
button_add.Clicked(o.addProfile)
|
||||
urt_profiles_buttons_vbox.PackStart(button_add, false, true, 5)
|
||||
urt_profiles_buttons_vbox.PackStart(button_add, false, true, 0)
|
||||
|
||||
button_edit := gtk.NewButtonWithLabel("Edit")
|
||||
button_edit.SetTooltipText("Edit selected profile. Do nothing if no profile was selected.")
|
||||
@@ -223,13 +237,13 @@ func (o *OptionsDialog) initializeUrtTab() {
|
||||
urt_profiles_buttons_vbox.PackStart(button_edit, false, true, 5)
|
||||
|
||||
// Spacer for profiles list buttons.
|
||||
sep := gtk.NewVSeparator()
|
||||
sep := gtk.NewVBox(false, 0)
|
||||
urt_profiles_buttons_vbox.PackStart(sep, true, true, 5)
|
||||
|
||||
button_delete := gtk.NewButtonWithLabel("Delete")
|
||||
button_delete.SetTooltipText("Delete selected profile. Do nothing if no profile was selected.")
|
||||
button_delete.Clicked(o.deleteProfile)
|
||||
urt_profiles_buttons_vbox.PackStart(button_delete, false, true, 5)
|
||||
urt_profiles_buttons_vbox.PackStart(button_delete, false, true, 0)
|
||||
|
||||
urt_hbox.Add(urt_profiles_buttons_vbox)
|
||||
|
||||
|
||||
@@ -27,8 +27,8 @@ import (
|
||||
type OptionsProfile struct {
|
||||
// Window.
|
||||
window *gtk.Window
|
||||
// Main Vertical Box.
|
||||
vbox *gtk.VBox
|
||||
// Main table.
|
||||
table *gtk.Table
|
||||
// Profile name.
|
||||
profile_name *gtk.Entry
|
||||
// Binary path.
|
||||
@@ -148,90 +148,85 @@ func (op *OptionsProfile) Initialize(update bool) {
|
||||
op.window.SetPosition(gtk.WIN_POS_CENTER)
|
||||
op.window.SetIcon(logo)
|
||||
|
||||
op.vbox = gtk.NewVBox(false, 0)
|
||||
|
||||
op.table = gtk.NewTable(6, 2, false)
|
||||
op.table.SetRowSpacings(2)
|
||||
|
||||
// Profile name.
|
||||
profile_name_tooltip := "This how you will see profile on profiles lists."
|
||||
pn_hbox := gtk.NewHBox(false, 0)
|
||||
pn_label := gtk.NewLabel("Profile name:")
|
||||
pn_label.SetTooltipText(profile_name_tooltip)
|
||||
profile_name_sep := gtk.NewHSeparator()
|
||||
profile_name_sep.SetTooltipText(profile_name_tooltip)
|
||||
pn_label.SetAlignment(0, 0)
|
||||
op.table.Attach(pn_label, 0, 1, 0, 1, gtk.FILL, gtk.SHRINK, 5, 5)
|
||||
|
||||
op.profile_name = gtk.NewEntry()
|
||||
op.profile_name.SetTooltipText(profile_name_tooltip)
|
||||
pn_hbox.PackStart(pn_label, false, true, 5)
|
||||
pn_hbox.PackStart(profile_name_sep, true, true, 5)
|
||||
pn_hbox.PackStart(op.profile_name, true, true, 5)
|
||||
op.vbox.PackStart(pn_hbox, false, true, 5)
|
||||
op.table.Attach(op.profile_name, 1, 2, 0, 1, gtk.FILL, gtk.FILL, 5, 5)
|
||||
|
||||
|
||||
// Urban Terror version.
|
||||
urt_version_tooltip := "Urban Terror version for which this profile applies."
|
||||
urt_version_hbox := gtk.NewHBox(false, 0)
|
||||
urt_version_label := gtk.NewLabel("Urban Terror version:")
|
||||
urt_version_label.SetTooltipText(urt_version_tooltip)
|
||||
urt_version_sep := gtk.NewHSeparator()
|
||||
urt_version_sep.SetTooltipText(urt_version_tooltip)
|
||||
urt_version_label.SetAlignment(0, 0)
|
||||
op.table.Attach(urt_version_label, 0, 1, 1, 2, gtk.FILL, gtk.SHRINK, 5, 5)
|
||||
|
||||
op.urt_version_combo = gtk.NewComboBoxText()
|
||||
op.urt_version_combo.SetTooltipText(urt_version_tooltip)
|
||||
op.urt_version_combo.AppendText("4.2.023")
|
||||
op.urt_version_combo.AppendText("4.3.0")
|
||||
op.urt_version_combo.AppendText("4.3.1")
|
||||
op.urt_version_combo.SetActive(1)
|
||||
urt_version_hbox.PackStart(urt_version_label, false, true, 5)
|
||||
urt_version_hbox.PackStart(urt_version_sep, true, true, 5)
|
||||
urt_version_hbox.PackStart(op.urt_version_combo, true, true, 5)
|
||||
op.vbox.PackStart(urt_version_hbox, false, true, 5)
|
||||
op.urt_version_combo.SetActive(2)
|
||||
op.table.Attach(op.urt_version_combo, 1, 2, 1, 2, gtk.FILL, gtk.FILL, 5, 5)
|
||||
|
||||
// Urban Terror binary path.
|
||||
select_binary_tooltip := "Urban Terror binary. Some checks will be executed, so make sure you have selected right binary:\n\nQuake3-UrT.i386 for linux-x86\nQuake3-UrT.x86_64 for linux-amd64\nQuake3-UrT.app for macOS"
|
||||
binpath_hbox := gtk.NewHBox(false, 0)
|
||||
binpath_label := gtk.NewLabel("Urban Terror binary:")
|
||||
binpath_label.SetTooltipText(select_binary_tooltip)
|
||||
binpath_sep := gtk.NewHSeparator()
|
||||
binpath_sep.SetTooltipText(select_binary_tooltip)
|
||||
binpath_label.SetAlignment(0, 0)
|
||||
op.table.Attach(binpath_label, 0, 1, 2, 3, gtk.FILL, gtk.SHRINK, 5, 5)
|
||||
|
||||
op.binary_path = gtk.NewEntry()
|
||||
op.binary_path.SetTooltipText(select_binary_tooltip)
|
||||
button_select_binary := gtk.NewButtonWithLabel("Browse")
|
||||
button_select_binary.SetTooltipText(select_binary_tooltip)
|
||||
button_select_binary.Clicked(op.browseForBinary)
|
||||
binpath_hbox.PackStart(binpath_label, false, true, 5)
|
||||
binpath_hbox.PackStart(binpath_sep, true, true, 5)
|
||||
binpath_hbox.PackStart(op.binary_path, true, true, 5)
|
||||
binpath_hbox.PackStart(button_select_binary, false, true, 5)
|
||||
op.vbox.PackStart(binpath_hbox, false, true, 5)
|
||||
op.table.Attach(binpath_hbox, 1, 2, 2, 3, gtk.FILL, gtk.FILL, 0, 0)
|
||||
|
||||
// Should we use additional X session?
|
||||
another_x_tooltip := "If this is checked, Urban Terror will be launched in another X session.\n\nThis could help if you're experiencing visual lag, glitches and FPS drops under compositing WMs, like Mutter and KWin."
|
||||
op.another_x_session = gtk.NewCheckButtonWithLabel("Start Urban Terror in another X session?")
|
||||
another_x_label := gtk.NewLabel("Start Urban Terror in another X session?")
|
||||
another_x_label.SetTooltipText(another_x_tooltip)
|
||||
another_x_label.SetAlignment(0, 0)
|
||||
op.table.Attach(another_x_label, 0, 1, 3, 4, gtk.FILL, gtk.SHRINK, 5, 5)
|
||||
op.another_x_session = gtk.NewCheckButtonWithLabel("")
|
||||
op.another_x_session.SetTooltipText(another_x_tooltip)
|
||||
op.vbox.PackStart(op.another_x_session, false, true, 5)
|
||||
// macOS can't do that :).
|
||||
// macOS and Windows can't do that :).
|
||||
if runtime.GOOS != "linux" {
|
||||
op.another_x_session.SetSensitive(false)
|
||||
}
|
||||
op.table.Attach(op.another_x_session, 1, 2, 3, 4, gtk.FILL, gtk.FILL, 5, 5)
|
||||
|
||||
// Additional game parameters.
|
||||
params_tooltip := "Additional parameters that will be passed to Urban Terror executable."
|
||||
params_hbox := gtk.NewHBox(false, 0)
|
||||
params_label := gtk.NewLabel("Additional parameters:")
|
||||
params_label.SetTooltipText(params_tooltip)
|
||||
params_sep := gtk.NewHSeparator()
|
||||
params_sep.SetTooltipText(params_tooltip)
|
||||
params_label.SetAlignment(0, 0)
|
||||
op.table.Attach(params_label, 0, 1, 4, 5, gtk.FILL, gtk.SHRINK, 5, 5)
|
||||
|
||||
op.additional_parameters = gtk.NewEntry()
|
||||
op.additional_parameters.SetTooltipText(params_tooltip)
|
||||
params_hbox.PackStart(params_label, false, true, 5)
|
||||
params_hbox.PackStart(params_sep, true, true, 5)
|
||||
params_hbox.PackStart(op.additional_parameters, true, true, 5)
|
||||
op.vbox.PackStart(params_hbox, false, true, 5)
|
||||
op.table.Attach(op.additional_parameters, 1, 2, 4, 5, gtk.FILL, gtk.FILL, 5, 5)
|
||||
|
||||
// Vertical separator.
|
||||
vert_sep := gtk.NewVSeparator()
|
||||
op.vbox.PackStart(vert_sep, true, true, 5)
|
||||
// Invisible thing.
|
||||
inv_label := gtk.NewLabel("")
|
||||
op.table.Attach(inv_label, 1, 2, 5, 6, gtk.EXPAND, gtk.FILL, 5, 5)
|
||||
|
||||
// The buttons.
|
||||
buttons_box := gtk.NewHBox(false, 0)
|
||||
buttons_sep := gtk.NewHSeparator()
|
||||
buttons_sep := gtk.NewHBox(false, 0)
|
||||
|
||||
cancel_button := gtk.NewButtonWithLabel("Cancel")
|
||||
cancel_button.SetTooltipText("Close without saving")
|
||||
@@ -251,9 +246,14 @@ func (op *OptionsProfile) Initialize(update bool) {
|
||||
add_button.Clicked(op.saveProfile)
|
||||
buttons_box.PackStart(add_button, false, true, 5)
|
||||
|
||||
op.vbox.PackStart(buttons_box, false, true, 5)
|
||||
vert_sep_box := gtk.NewVBox(false, 0)
|
||||
|
||||
op.window.Add(op.vbox)
|
||||
vbox := gtk.NewVBox(false, 0)
|
||||
vbox.PackStart(op.table, false, true, 5)
|
||||
vbox.PackStart(vert_sep_box, true, true, 5)
|
||||
vbox.PackStart(buttons_box, false, true, 5)
|
||||
|
||||
op.window.Add(vbox)
|
||||
op.window.ShowAll()
|
||||
}
|
||||
|
||||
@@ -262,26 +262,23 @@ func (op *OptionsProfile) InitializeUpdate(profile_name string) {
|
||||
op.Initialize(true)
|
||||
|
||||
// Get profile data.
|
||||
profile := []datamodels.Profile{}
|
||||
err := ctx.Database.Db.Select(&profile, ctx.Database.Db.Rebind("SELECT * FROM urt_profiles WHERE name=?"), profile_name)
|
||||
if err != nil {
|
||||
fmt.Println(err.Error())
|
||||
}
|
||||
|
||||
op.profile_name.SetText(profile[0].Name)
|
||||
op.binary_path.SetText(profile[0].Binary)
|
||||
op.additional_parameters.SetText(profile[0].Additional_params)
|
||||
if profile[0].Second_x_session == "1" {
|
||||
profile := ctx.Cache.Profiles[profile_name].Profile
|
||||
op.profile_name.SetText(profile.Name)
|
||||
op.binary_path.SetText(profile.Binary)
|
||||
op.additional_parameters.SetText(profile.Additional_params)
|
||||
if profile.Second_x_session == "1" {
|
||||
op.another_x_session.SetActive(true)
|
||||
}
|
||||
|
||||
if profile[0].Version == "4.3.0" {
|
||||
if profile.Version == "4.3.0" {
|
||||
op.urt_version_combo.SetActive(1)
|
||||
} else if profile.Version == "4.3.1" {
|
||||
op.urt_version_combo.SetActive(2)
|
||||
} else {
|
||||
op.urt_version_combo.SetActive(0)
|
||||
}
|
||||
|
||||
op.old_profile = &profile[0]
|
||||
op.old_profile = profile
|
||||
|
||||
}
|
||||
|
||||
|
||||
104
ui/server_cvars.go
Normal file
104
ui/server_cvars.go
Normal file
@@ -0,0 +1,104 @@
|
||||
// URTator - Urban Terror server browser and game launcher, written in
|
||||
// Go.
|
||||
//
|
||||
// Copyright (c) 2016, Stanslav N. a.k.a pztrn (or p0z1tr0n)
|
||||
// All rights reserved.
|
||||
//
|
||||
// Licensed under Terms and Conditions of GNU General Public License
|
||||
// version 3 or any higher.
|
||||
// ToDo: put full text of license here.
|
||||
package ui
|
||||
|
||||
import (
|
||||
// stdlib
|
||||
"fmt"
|
||||
"sort"
|
||||
|
||||
// Local
|
||||
"github.com/pztrn/urtrator/ioq3dataparser"
|
||||
|
||||
// Other
|
||||
"github.com/mattn/go-gtk/gtk"
|
||||
"github.com/mattn/go-gtk/glib"
|
||||
)
|
||||
|
||||
type ServerCVarsDialog struct {
|
||||
// Window.
|
||||
window *gtk.Window
|
||||
// Main Vertical Box.
|
||||
vbox *gtk.VBox
|
||||
// Treeview for CVars.
|
||||
treeview *gtk.TreeView
|
||||
// Store for treeview.
|
||||
treeview_store *gtk.ListStore
|
||||
}
|
||||
|
||||
func (scd *ServerCVarsDialog) Close() {
|
||||
scd.window.Destroy()
|
||||
}
|
||||
|
||||
func (scd *ServerCVarsDialog) fill(srv_address string) {
|
||||
server_info := ctx.Cache.Servers[srv_address].Server
|
||||
parsed_general_data := ioq3dataparser.ParseInfoToMap(server_info.ExtendedConfig)
|
||||
|
||||
// Sort it!
|
||||
general_data_keys := make([]string, 0, len(parsed_general_data))
|
||||
for k := range parsed_general_data {
|
||||
general_data_keys = append(general_data_keys, k)
|
||||
}
|
||||
|
||||
sort.Strings(general_data_keys)
|
||||
|
||||
for k := range general_data_keys {
|
||||
iter := new(gtk.TreeIter)
|
||||
scd.treeview_store.Append(iter)
|
||||
scd.treeview_store.SetValue(iter, 0, general_data_keys[k])
|
||||
scd.treeview_store.SetValue(iter, 1, parsed_general_data[general_data_keys[k]])
|
||||
}
|
||||
}
|
||||
|
||||
func (scd *ServerCVarsDialog) Initialize(w *gtk.Window, srv_address string) {
|
||||
fmt.Println("Showing server's CVars...")
|
||||
|
||||
scd.initializeStorages()
|
||||
|
||||
scd.window = gtk.NewWindow(gtk.WINDOW_TOPLEVEL)
|
||||
scd.window.SetTitle("URTrator - Server CVars")
|
||||
scd.window.Connect("destroy", scd.Close)
|
||||
scd.window.SetTransientFor(w)
|
||||
scd.window.SetDefaultSize(300, 400)
|
||||
|
||||
scd.vbox = gtk.NewVBox(false, 0)
|
||||
scd.window.Add(scd.vbox)
|
||||
|
||||
// CVars scrolls.
|
||||
si := gtk.NewScrolledWindow(nil, nil)
|
||||
scd.vbox.PackStart(si, true, true, 5)
|
||||
|
||||
// CVars list.
|
||||
scd.treeview = gtk.NewTreeView()
|
||||
scd.treeview.SetModel(scd.treeview_store)
|
||||
si.Add(scd.treeview)
|
||||
|
||||
scd.treeview.AppendColumn(gtk.NewTreeViewColumnWithAttributes("Key", gtk.NewCellRendererText(), "markup", 0))
|
||||
scd.treeview.AppendColumn(gtk.NewTreeViewColumnWithAttributes("Value", gtk.NewCellRendererText(), "markup", 1))
|
||||
|
||||
// Close button.
|
||||
hbox := gtk.NewHBox(false, 0)
|
||||
scd.vbox.PackStart(hbox, false, true, 5)
|
||||
|
||||
sep := gtk.NewHBox(false, 0)
|
||||
hbox.PackStart(sep, true, true, 5)
|
||||
|
||||
close_button := gtk.NewButtonWithLabel("Close")
|
||||
close_button.Clicked(scd.Close)
|
||||
hbox.PackStart(close_button, false, true, 5)
|
||||
|
||||
scd.fill(srv_address)
|
||||
|
||||
scd.window.ShowAll()
|
||||
}
|
||||
|
||||
func (scd *ServerCVarsDialog) initializeStorages() {
|
||||
scd.treeview_store = gtk.NewListStore(glib.G_TYPE_STRING, glib.G_TYPE_STRING)
|
||||
}
|
||||
@@ -1,33 +0,0 @@
|
||||
// URTator - Urban Terror server browser and game launcher, written in
|
||||
// Go.
|
||||
//
|
||||
// Copyright (c) 2016, Stanslav N. a.k.a pztrn (or p0z1tr0n)
|
||||
// All rights reserved.
|
||||
//
|
||||
// Licensed under Terms and Conditions of GNU General Public License
|
||||
// version 3 or any higher.
|
||||
// ToDo: put full text of license here.
|
||||
package ui
|
||||
|
||||
import (
|
||||
// stdlib
|
||||
"fmt"
|
||||
|
||||
// Local
|
||||
//"github.com/pztrn/urtrator/datamodels"
|
||||
|
||||
// Other
|
||||
"github.com/mattn/go-gtk/gtk"
|
||||
//"github.com/mattn/go-gtk/glib"
|
||||
)
|
||||
|
||||
type ServerInfoDialog struct {
|
||||
// Window.
|
||||
window *gtk.Window
|
||||
// Main Vertical Box.
|
||||
vbox *gtk.VBox
|
||||
}
|
||||
|
||||
func (sid *ServerInfoDialog) Initialize() {
|
||||
fmt.Println("Showing server's information...")
|
||||
}
|
||||
Reference in New Issue
Block a user