29 Commits

Author SHA1 Message Date
e66875ffbe Version bump. 2016-11-26 19:32:37 +05:00
979de8d858 Filtering by game mode implemented. 2016-11-26 16:20:57 +05:00
f0ddda1af5 "All versions" instead of "All" in version select comboboxes. 2016-11-26 16:06:33 +05:00
bd344fee2e Filter by server version and forgotten server's CVars window.
Implemented filtering servers by server's version, related to #27.
This combobox is saved-restored across restarts.

Added forgotten bd04870 server_cvars.go, which is responsible for
showing server's CVars window.
2016-11-26 16:00:17 +05:00
7950ab5a1f macOS might have no GTK configuration, so forcing "only icons" for toolbar. 2016-11-26 09:35:59 +05:00
3b3aae16b0 Accidently attached wrong widget. 2016-11-26 09:27:46 +05:00
a57c878dad Prettified favorites add/edit dialog. Fixes #33. 2016-11-26 09:24:36 +05:00
474821ba7b Ooops :) 2016-11-26 09:11:51 +05:00
f32cf4d1f6 "GENERAL INFO" list item isn't needed anymore. 2016-11-26 09:10:57 +05:00
bd04870aa3 Splitted sidebar's list into two and separate CVars window.
Splitted sidebar's list into two separate lists - one for
general server's info (hostname, players, etc.) and one for
players list.

Also, moved CVars list to separate window which can be shown by
clicking approriate button under player's list.
2016-11-26 09:05:48 +05:00
280c65f116 Distinguish bots from humans.
Players column now have three integers - first is real humans
count, second - bots count, and third - maximum players allowed
on this server. Also, sidebar will show bots count as well.
2016-11-26 07:38:26 +05:00
32c6297765 Fixed game version combobox not selecting proper version on profile editing. 2016-11-25 04:49:19 +05:00
190f76eb82 Fixed profiles editing crashing application if profile wasn't saved in database. 2016-11-25 04:44:46 +05:00
5c295f08ab Prettify options window. 2016-11-25 04:31:45 +05:00
061bfcaeb9 UI design updates.
Got rid of visible separators, replaced them with HBox and VBox.

Reworked profile add/edit window, now it looks prettier and
organic.
2016-11-25 04:11:44 +05:00
5ca8299714 Show selected server's information on active tab changing.
URTrator will now show information about selected server on
activated tab. E.g. when you switched from "Servers" to
"Favorites", sidebar informational widget will be updated with
server's data for selected server on "Favorites" tab.
2016-11-25 03:12:05 +05:00
9c8aa1cc34 Preparing to 0.1.0 release. 2016-11-23 10:13:01 +05:00
5fcbd8536c Update selected server's info in sidebar after updating server's data. 2016-11-23 10:10:11 +05:00
fb7a471aec Shw message in toolbar when updating selected server's data. 2016-11-23 10:02:58 +05:00
8c9d948a52 Fixed tooltip text for "Update all servers" button. 2016-11-23 09:53:09 +05:00
8b44d194b5 Hide private servers checkboxes. 2016-11-23 09:49:39 +05:00
3b0a93e63a By default srting players by name as well as cvars in sidebar. 2016-11-23 07:51:41 +05:00
b85ba0470c Fixed rendering of logo on launch button.
Also, made this logo smaller to beautify interface.
2016-11-23 07:42:58 +05:00
f127fdc9f4 Fixed players counting on servers update. 2016-11-23 07:41:14 +05:00
5ef54d943e Removed unneded "Additional information" button. 2016-11-23 07:35:10 +05:00
9e6cdfc869 Increased max ping requests to servers. Fixes #3. 2016-11-22 18:50:56 +05:00
bfd3f884b3 Automatic profile selection. Fixes #14.
Automatically select first added profile on every profiles list
update. Yes, quick hack. In future we will autodetect profiles
based on server version, and profiles combobox will only be
needed for quick connect.
2016-11-22 18:33:53 +05:00
7e6b698c1c Proper sorting by servers names. Fixing #12. 2016-11-22 18:23:43 +05:00
4516abb916 go-gtk fixed default sorting, so unlock it for all OSes. 2016-11-22 17:14:02 +05:00
16 changed files with 640 additions and 174 deletions

View File

@@ -2,6 +2,8 @@
[![Join the chat at https://gitter.im/urtrator/Lobby](https://badges.gitter.im/urtrator/Lobby.svg)](https://gitter.im/urtrator/Lobby?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) [![Join the chat at https://gitter.im/urtrator/Lobby](https://badges.gitter.im/urtrator/Lobby.svg)](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).
![Main Window](/doc/screenshots/0.1-main_window.png) ![Main Window](/doc/screenshots/0.1-main_window.png)
URTrator is a desktop application that should (eventually) replace URTrator is a desktop application that should (eventually) replace

View File

@@ -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].Port = s.Server.Port
new_servers[mapping_item_name].Name = s.Server.Name new_servers[mapping_item_name].Name = s.Server.Name
new_servers[mapping_item_name].Players = s.Server.Players 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].Maxplayers = s.Server.Maxplayers
new_servers[mapping_item_name].Ping = s.Server.Ping new_servers[mapping_item_name].Ping = s.Server.Ping
new_servers[mapping_item_name].Map = s.Server.Map 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].Port = s.Server.Port
cached_servers[mapping_item_name].Name = s.Server.Name cached_servers[mapping_item_name].Name = s.Server.Name
cached_servers[mapping_item_name].Players = s.Server.Players 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].Maxplayers = s.Server.Maxplayers
cached_servers[mapping_item_name].Ping = s.Server.Ping cached_servers[mapping_item_name].Ping = s.Server.Ping
cached_servers[mapping_item_name].Map = s.Server.Map 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...") fmt.Println("Adding new servers...")
if len(new_servers) > 0 { if len(new_servers) > 0 {
for _, srv := range new_servers { 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...") fmt.Println("Updating cached servers...")
for _, srv := range 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 { if err != nil {
fmt.Println(err.Error()) 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.Ip = server.Ip
c.Servers[key].Server.Port = server.Port c.Servers[key].Server.Port = server.Port
c.Servers[key].Server.Players = server.Players 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.Maxplayers = server.Maxplayers
c.Servers[key].Server.Ping = server.Ping c.Servers[key].Server.Ping = server.Ping
c.Servers[key].Server.Gamemode = server.Gamemode c.Servers[key].Server.Gamemode = server.Gamemode

View File

@@ -10,5 +10,11 @@
package common package common
const ( const (
URTRATOR_VERSION = "0.1-beta5" URTRATOR_VERSION = "0.1.1"
) )
// Self-named.
var SUPPORTED_URT_VERSIONS []string = []string{
"4.2.023",
"4.3.1",
}

View File

@@ -48,6 +48,7 @@ func migrate_full(db *Database, version int) {
if version == 6 {six_to_seven(db); version = 7} if version == 6 {six_to_seven(db); version = 7}
if version == 7 {seven_to_eight(db); version = 8} if version == 7 {seven_to_eight(db); version = 8}
if version == 8 {eight_to_nine(db); version = 9} if version == 8 {eight_to_nine(db); version = 9}
if version == 9 {nine_to_ten(db); version = 10}
} }
// Initial database structure. // 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("ALTER TABLE servers ADD is_private VARCHAR(1) NOT NULL DEFAULT '0'")
db.Db.MustExec("UPDATE database SET version=9") 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")
}

View File

@@ -18,6 +18,8 @@ type Server struct {
Name string `db:"name"` Name string `db:"name"`
// Current players count // Current players count
Players string `db:"players"` Players string `db:"players"`
// Bots count
Bots string `db:"bots"`
// Maximum players // Maximum players
Maxplayers string `db:"maxplayers"` Maxplayers string `db:"maxplayers"`
// Ping // Ping

View File

@@ -150,6 +150,9 @@ ln -s ../../../Framework .
cd ../../../MacOS 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 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 "Finishing..."
echo "URTrator is ready! Copy URTrator.app bundle to Applications and launch it!" echo "URTrator is ready! Copy URTrator.app bundle to Applications and launch it!"

View File

@@ -34,7 +34,7 @@ type Pooler struct {
func (p *Pooler) Initialize() { func (p *Pooler) Initialize() {
fmt.Println("Initializing requester goroutine pooler...") fmt.Println("Initializing requester goroutine pooler...")
// ToDo: figure out how to make this work nice. // ToDo: figure out how to make this work nice.
p.maxrequests = 100 p.maxrequests = 200
_ = runtime.GOMAXPROCS(runtime.NumCPU() * 4) _ = runtime.GOMAXPROCS(runtime.NumCPU() * 4)
p.pp = "\377\377\377\377" p.pp = "\377\377\377\377"
fmt.Println("Pooler initialized") fmt.Println("Pooler initialized")
@@ -234,11 +234,34 @@ func (p *Pooler) UpdateSpecificServer(server *datamodels.Server) error {
if len(received_lines) >= 2 { if len(received_lines) >= 2 {
// Here we go, players information. // Here we go, players information.
players := received_lines[2:] players := received_lines[2:]
var real_players int = 0
var bots int = 0
// Calculate players! // Calculate players!
if len(players) == 1 && len(players[0]) > 255 { if len(players) == 1 && len(players[0]) > 255 {
server.Players = "0" server.Players = "0"
server.Bots = "0"
} else { } 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:], "\\") server.PlayersInfo = strings.Join(received_lines[2:], "\\")
} }

View File

@@ -118,7 +118,6 @@ func (f *FavoriteDialog) initializeWindow() {
f.window.SetModal(true) f.window.SetModal(true)
f.window.SetSizeRequest(400, 200) f.window.SetSizeRequest(400, 200)
f.window.SetResizable(false) f.window.SetResizable(false)
f.vbox = gtk.NewVBox(false, 0)
// Load program icon from base64. // Load program icon from base64.
icon_bytes, _ := base64.StdEncoding.DecodeString(common.Logo) icon_bytes, _ := base64.StdEncoding.DecodeString(common.Logo)
@@ -132,25 +131,27 @@ func (f *FavoriteDialog) initializeWindow() {
gtk_opts := gtk_opts_raw.ToGObject() gtk_opts := gtk_opts_raw.ToGObject()
gtk_opts.Set("gtk-button-images", true) 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. // 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_label := gtk.NewLabel("Server name:")
srv_name_hbox.PackStart(srv_name_label, false, true, 5) srv_name_label.SetAlignment(0, 0)
srv_name_sep := gtk.NewHSeparator() table.Attach(srv_name_label, 0, 1, 0, 1, gtk.FILL, gtk.SHRINK, 5, 5)
srv_name_hbox.PackStart(srv_name_sep, true, true, 5)
f.server_name = gtk.NewEntry() 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. // 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_label := gtk.NewLabel("Server address:")
srv_addr_hbox.PackStart(srv_addr_label, false, true, 5) srv_addr_label.SetAlignment(0, 0)
srv_addr_sep := gtk.NewHSeparator() table.Attach(srv_addr_label, 0, 1, 1, 2, gtk.FILL, gtk.SHRINK, 5, 5)
srv_addr_hbox.PackStart(srv_addr_sep, true, true, 5)
srv_addr_hbox := gtk.NewHBox(false, 0)
f.server_address = gtk.NewEntry() 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 := gtk.NewButton()
srv_addr_update_btn.SetTooltipText("Update server information") srv_addr_update_btn.SetTooltipText("Update server information")
srv_addr_update_btn_image := gtk.NewImageFromStock(gtk.STOCK_REDO, gtk.ICON_SIZE_SMALL_TOOLBAR) 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 { if f.update {
f.server_address.SetSensitive(false) f.server_address.SetSensitive(false)
} }
table.Attach(srv_addr_hbox, 1, 2, 1, 2, gtk.FILL, gtk.FILL, 5, 5)
// Server password. // 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_label := gtk.NewLabel("Password:")
srv_pass_hbox.PackStart(srv_pass_label, false, true, 5) srv_pass_label.SetAlignment(0, 0)
srv_pass_sep := gtk.NewHSeparator() table.Attach(srv_pass_label, 0, 1, 2, 3, gtk.FILL, gtk.SHRINK, 5, 5)
srv_pass_hbox.PackStart(srv_pass_sep, true, true, 5)
f.server_password = gtk.NewEntry() 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 to use.
profile_hbox := gtk.NewHBox(false, 0)
f.vbox.PackStart(profile_hbox, false, true, 5)
profile_label := gtk.NewLabel("Profile:") profile_label := gtk.NewLabel("Profile:")
profile_hbox.PackStart(profile_label, false, true, 5) profile_label.SetAlignment(0, 0)
profile_sep := gtk.NewHSeparator() table.Attach(profile_label, 0, 1, 3, 4, gtk.FILL, gtk.SHRINK, 5, 5)
profile_hbox.PackStart(profile_sep, true, true, 5)
f.profile = gtk.NewComboBoxText() 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.
buttons_hbox := gtk.NewHBox(false, 0) buttons_hbox := gtk.NewHBox(false, 0)

View File

@@ -13,6 +13,7 @@ import (
// stdlib // stdlib
"fmt" "fmt"
"runtime" "runtime"
"sort"
"strconv" "strconv"
"strings" "strings"
@@ -59,12 +60,26 @@ type MainWindow struct {
profiles *gtk.ComboBoxText profiles *gtk.ComboBoxText
// Checkbox for hiding/showing offline servers in 'Servers' tab list. // Checkbox for hiding/showing offline servers in 'Servers' tab list.
all_servers_hide_offline *gtk.CheckButton 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. // Checkbox for hiding/showing offline servers in 'Favorites' tab list.
fav_servers_hide_offline *gtk.CheckButton 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. // Game launch button.
launch_button *gtk.Button launch_button *gtk.Button
// Server's information. // Server's main information.
server_info *gtk.TreeView server_info *gtk.TreeView
// Players information.
players_info *gtk.TreeView
// Quick connect: server address // Quick connect: server address
qc_server_address *gtk.Entry qc_server_address *gtk.Entry
// Quick connect: password // Quick connect: password
@@ -87,9 +102,12 @@ type MainWindow struct {
fav_servers_store *gtk.ListStore fav_servers_store *gtk.ListStore
// Server's information store. // Server's information store.
server_info_store *gtk.ListStore server_info_store *gtk.ListStore
// Players information store.
players_info_store *gtk.ListStore
// Dialogs. // Dialogs.
options_dialog *OptionsDialog options_dialog *OptionsDialog
server_cvars_dialog *ServerCVarsDialog
// Other // Other
// Old profiles count. // Old profiles count.
@@ -127,8 +145,14 @@ type MainWindow struct {
// Flags. // Flags.
// Application is initialized?
initialized bool
// Window is hidden? // Window is hidden?
hidden bool 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() { 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 // Executes when delimiter for two panes is moved, to calculate VALID
// position. // position.
func (m *MainWindow) checkMainPanePosition() { 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 // Executes when "Hide offline servers" checkbox changed it's state on
// "Servers" tab. // "Servers" tab.
func (m *MainWindow) hideOfflineAllServers() { func (m *MainWindow) hideOfflineAllServers() {
@@ -310,6 +354,18 @@ func (m *MainWindow) hideOfflineAllServers() {
ctx.Eventer.LaunchEvent("loadAllServers", map[string]string{}) 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 // Executes when "Hide offline servers" checkbox changed it's state on
// "Favorites" tab. // "Favorites" tab.
func (m *MainWindow) hideOfflineFavoriteServers() { func (m *MainWindow) hideOfflineFavoriteServers() {
@@ -322,6 +378,18 @@ func (m *MainWindow) hideOfflineFavoriteServers() {
ctx.Eventer.LaunchEvent("loadFavoriteServers", map[string]string{}) 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) { func (m *MainWindow) loadAllServers(data map[string]string) {
fmt.Println("Loading all servers...") fmt.Println("Loading all servers...")
for _, server := range ctx.Cache.Servers { for _, server := range ctx.Cache.Servers {
@@ -335,6 +403,7 @@ func (m *MainWindow) loadAllServers(data map[string]string) {
iter = server.AllServersIter iter = server.AllServersIter
} }
// Hide offline servers?
if m.all_servers_hide_offline.GetActive() && (server.Server.Players == "" && server.Server.Maxplayers == "" || ping > 9000) { if m.all_servers_hide_offline.GetActive() && (server.Server.Players == "" && server.Server.Maxplayers == "" || ping > 9000) {
if server.AllServersIterInList && server.AllServersIterSet { if server.AllServersIterInList && server.AllServersIterSet {
m.all_servers_store.Remove(iter) m.all_servers_store.Remove(iter)
@@ -343,6 +412,36 @@ func (m *MainWindow) loadAllServers(data map[string]string) {
continue 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 { if !server.AllServersIterInList && server.AllServersIterSet {
m.all_servers_store.Append(iter) m.all_servers_store.Append(iter)
server.AllServersIterInList = true 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"]["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"]["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"]["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"]["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"]["Version"], server.Server.Version)
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)
@@ -387,6 +486,7 @@ func (m *MainWindow) loadFavoriteServers(data map[string]string) {
iter = server.FavServersIter iter = server.FavServersIter
} }
// Hide offline servers?
if m.fav_servers_hide_offline.GetActive() && (server.Server.Players == "" && server.Server.Maxplayers == "" || ping > 9000) { 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)
@@ -395,6 +495,36 @@ func (m *MainWindow) loadFavoriteServers(data map[string]string) {
continue 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 // If server on favorites widget, but not favorited (e.g. just
// removed from favorites) - remove it from list. // removed from favorites) - remove it from list.
if server.Server.Favorite != "1" && server.FavServersIterSet && server.FavServersIterInList { 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"]["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"]["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"]["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"]["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"]["Version"], server.Server.Version)
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)
@@ -453,10 +583,40 @@ func (m *MainWindow) loadProfiles(data map[string]string) {
m.old_profiles_count = len(ctx.Cache.Profiles) m.old_profiles_count = len(ctx.Cache.Profiles)
fmt.Println("Added " + strconv.Itoa(m.old_profiles_count) + " 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) { func (m *MainWindow) serversUpdateCompleted(data map[string]string) {
ctx.Eventer.LaunchEvent("setToolbarLabelText", map[string]string{"text": "Servers updated."}) 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) { func (m *MainWindow) setQuickConnectDetails(data map[string]string) {
@@ -487,14 +647,33 @@ func (m *MainWindow) showHide() {
} }
} }
func (m *MainWindow) showServerInformation() { func (m *MainWindow) showServerCVars() {
fmt.Println("Showing server's information...") 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() { func (m *MainWindow) showShortServerInformation() {
fmt.Println("Server selection changed, updating server's information widget...") fmt.Println("Server selection changed, updating server's information widget...")
m.server_info_store.Clear() m.server_info_store.Clear()
m.players_info_store.Clear()
current_tab := m.tab_widget.GetTabLabelText(m.tab_widget.GetNthPage(m.tab_widget.GetCurrentPage())) 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) srv_address := m.getIpFromServersList(current_tab)
// Getting server information from cache. // Getting server information from cache.
@@ -505,12 +684,8 @@ func (m *MainWindow) showShortServerInformation() {
// Append to treeview generic info first. After appending it // Append to treeview generic info first. After appending it
// will be deleted from map. // 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. // Server's name.
iter = new(gtk.TreeIter) iter := new(gtk.TreeIter)
m.server_info_store.Append(iter) m.server_info_store.Append(iter)
m.server_info_store.SetValue(iter, 0, "Server's name") 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"])) 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) iter = new(gtk.TreeIter)
m.server_info_store.Append(iter) m.server_info_store.Append(iter)
m.server_info_store.SetValue(iter, 0, "Players") 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") delete(parsed_general_data, "sv_maxclients")
// Ping // Ping
@@ -558,23 +733,26 @@ func (m *MainWindow) showShortServerInformation() {
} }
m.server_info_store.SetValue(iter, 1, passworded_status) m.server_info_store.SetValue(iter, 1, passworded_status)
// Just a separator. // Sorting keys of map.
iter = new(gtk.TreeIter) players_map_keys := make([]string, 0, len(parsed_players_info))
m.server_info_store.Append(iter) for k := range parsed_players_info {
// ToDo: figure out how to do this properly without
// Players information // append().
iter = new(gtk.TreeIter) players_map_keys = append(players_map_keys, k)
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"] + ")")
} }
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. // Just a separator.
iter = new(gtk.TreeIter) iter = new(gtk.TreeIter)
m.server_info_store.Append(iter) m.server_info_store.Append(iter)
@@ -584,12 +762,21 @@ func (m *MainWindow) showShortServerInformation() {
m.server_info_store.Append(iter) m.server_info_store.Append(iter)
m.server_info_store.SetValue(iter, 0, "<markup><span font_weight=\"bold\">OTHER PARAMETERS</span></markup>") 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) iter = new(gtk.TreeIter)
m.server_info_store.Append(iter) m.server_info_store.Append(iter)
m.server_info_store.SetValue(iter, 0, key) m.server_info_store.SetValue(iter, 0, general_data_keys[k])
m.server_info_store.SetValue(iter, 1, value) 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() { 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())) current_tab := m.tab_widget.GetTabLabelText(m.tab_widget.GetNthPage(m.tab_widget.GetCurrentPage()))
srv_address := m.getIpFromServersList(current_tab) srv_address := m.getIpFromServersList(current_tab)

View File

@@ -5,6 +5,7 @@ import (
"encoding/base64" "encoding/base64"
"fmt" "fmt"
"runtime" "runtime"
"sort"
"strconv" "strconv"
// local // local
@@ -84,6 +85,7 @@ func (m *MainWindow) Initialize() {
// Dialogs initialization. // Dialogs initialization.
m.options_dialog = &OptionsDialog{} m.options_dialog = &OptionsDialog{}
m.server_cvars_dialog = &ServerCVarsDialog{}
// Main menu. // Main menu.
if runtime.GOOS == "darwin" { if runtime.GOOS == "darwin" {
@@ -130,7 +132,7 @@ func (m *MainWindow) Initialize() {
m.vbox.PackStart(profile_and_launch_hbox, false, true, 5) m.vbox.PackStart(profile_and_launch_hbox, false, true, 5)
// Separator // Separator
sep := gtk.NewHSeparator() sep := gtk.NewHBox(false, 0)
profile_and_launch_hbox.PackStart(sep, true, true, 5) profile_and_launch_hbox.PackStart(sep, true, true, 5)
// Profile selection. // Profile selection.
@@ -149,12 +151,16 @@ func (m *MainWindow) Initialize() {
m.launch_button = gtk.NewButtonWithLabel("Launch!") m.launch_button = gtk.NewButtonWithLabel("Launch!")
m.launch_button.SetTooltipText("Launch Urban Terror") m.launch_button.SetTooltipText("Launch Urban Terror")
m.launch_button.Clicked(m.launchGame) 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) m.launch_button.SetImage(launch_button_image)
profile_and_launch_hbox.PackStart(m.launch_button, false, true, 5) profile_and_launch_hbox.PackStart(m.launch_button, false, true, 5)
m.window.Add(m.vbox) m.window.Add(m.vbox)
if runtime.GOOS == "darwin" {
m.initializeMacAfter()
}
m.window.ShowAll() m.window.ShowAll()
// Launch events. // Launch events.
@@ -165,6 +171,9 @@ func (m *MainWindow) Initialize() {
ctx.Eventer.LaunchEvent("loadFavoriteServers", map[string]string{}) ctx.Eventer.LaunchEvent("loadFavoriteServers", map[string]string{})
ctx.Eventer.LaunchEvent("setToolbarLabelText", map[string]string{"text": "URTrator is ready."}) 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() gtk.Main()
} }
@@ -236,6 +245,7 @@ func (m *MainWindow) initializeSidebar() {
// Scrolled thing. // Scrolled thing.
si_scroll := gtk.NewScrolledWindow(nil, nil) si_scroll := gtk.NewScrolledWindow(nil, nil)
si_scroll.SetPolicy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
si_vbox.PackStart(si_scroll, true, true, 5) si_vbox.PackStart(si_scroll, true, true, 5)
// Server's information. // Server's information.
@@ -250,10 +260,32 @@ func (m *MainWindow) initializeSidebar() {
si_scroll.Add(m.server_info) si_scroll.Add(m.server_info)
// Button to view additional server info. // Players information.
additional_srv_info_button := gtk.NewButtonWithLabel("Additional information") players_info_frame := gtk.NewFrame("Players")
additional_srv_info_button.Clicked(m.showServerInformation) sidebar_vbox.PackStart(players_info_frame, true, true, 5)
si_vbox.PackStart(additional_srv_info_button, false, 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.
quick_connect_frame := gtk.NewFrame("Quick connect") quick_connect_frame := gtk.NewFrame("Quick connect")
@@ -296,6 +328,9 @@ func (m *MainWindow) initializeSidebar() {
// Initializes internal storages. // Initializes internal storages.
func (m *MainWindow) initializeStorages() { func (m *MainWindow) initializeStorages() {
// Application isn't initialized.
m.initialized = false
m.use_other_servers_tab = false
// Gamemodes. // Gamemodes.
m.gamemodes = make(map[string]string) m.gamemodes = make(map[string]string)
m.gamemodes = 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. // 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) 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. // Profiles count after filling combobox. Defaulting to 0.
m.old_profiles_count = 0 m.old_profiles_count = 0
@@ -384,6 +423,7 @@ func (m *MainWindow) initializeStorages() {
func (m *MainWindow) InitializeTabs() { func (m *MainWindow) InitializeTabs() {
// Create tabs widget. // Create tabs widget.
m.tab_widget = gtk.NewNotebook() m.tab_widget = gtk.NewNotebook()
m.tab_widget.Connect("switch-page", m.tabChanged)
tab_allsrv_hbox := gtk.NewHBox(false, 0) tab_allsrv_hbox := gtk.NewHBox(false, 0)
swin1 := gtk.NewScrolledWindow(nil, nil) swin1 := gtk.NewScrolledWindow(nil, nil)
@@ -439,12 +479,7 @@ func (m *MainWindow) InitializeTabs() {
// Sorting. // Sorting.
// By default we are sorting by server name. // 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)
// For some reason this cause panic on Windows, so disabling
// default sorting here.
if runtime.GOOS != "windows" {
m.all_servers_store_sortable.SetSortColumnId(m.column_pos["Servers"]["Name"], gtk.SORT_ASCENDING)
}
// Sorting functions. // Sorting functions.
// Race conditions and GC crazyness appears when activated, so for // Race conditions and GC crazyness appears when activated, so for
@@ -476,8 +511,64 @@ func (m *MainWindow) InitializeTabs() {
} }
} }
// 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. // Final separator.
ctl_sep := gtk.NewVSeparator() ctl_sep := gtk.NewVBox(false, 0)
tab_all_srv_ctl_vbox.PackStart(ctl_sep, true, true, 5) tab_all_srv_ctl_vbox.PackStart(ctl_sep, true, true, 5)
// Favorites servers // Favorites servers
@@ -557,8 +648,58 @@ func (m *MainWindow) InitializeTabs() {
} }
} }
// 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. // 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) tab_fav_srv_ctl_vbox.PackStart(ctl_fav_sep, true, true, 5)
// Add tab_widget widget to window. // Add tab_widget widget to window.
@@ -577,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_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_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 := 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) button_update_all_servers.OnClicked(m.UpdateServers)
m.toolbar.Insert(button_update_all_servers, 0) m.toolbar.Insert(button_update_all_servers, 0)

View File

@@ -21,6 +21,10 @@ func (m *MainWindow) initializeMac() {
} }
} }
func (m *MainWindow) initializeMacAfter() {
m.toolbar.SetStyle(gtk.TOOLBAR_ICONS)
}
func (m *MainWindow) initializeMacMenu() { func (m *MainWindow) initializeMacMenu() {
// This is a placeholder, in future we will use native mac menu. // This is a placeholder, in future we will use native mac menu.
// For now it launches default menu initialization. // For now it launches default menu initialization.

View File

@@ -25,8 +25,8 @@ func (m *MainWindow) sortServersByName(model *gtk.TreeModel, a *gtk.TreeIter, b
return 0 return 0
} }
name1 := ctx.Colorizer.ClearFromMarkup(name1_raw.GetString()) name1 := strings.ToLower(ctx.Colorizer.ClearFromMarkup(name1_raw.GetString()))
name2 := ctx.Colorizer.ClearFromMarkup(name2_raw.GetString()) name2 := strings.ToLower(ctx.Colorizer.ClearFromMarkup(name2_raw.GetString()))
if name1 < name2 { if name1 < name2 {
return -1 return -1

View File

@@ -146,15 +146,33 @@ func (o *OptionsDialog) initializeAppearanceTab() {
func (o *OptionsDialog) initializeGeneralTab() { func (o *OptionsDialog) initializeGeneralTab() {
general_vbox := gtk.NewVBox(false, 0) general_vbox := gtk.NewVBox(false, 0)
general_table := gtk.NewTable(2, 2, false)
// Tray icon checkbox. // 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") 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. // Autoupdate checkbox.
o.autoupdate = gtk.NewCheckButtonWithLabel("Automatically update URTrator?") autoupdate_tooltip := "Should URTrator check for updates and update itself? Not working now."
o.autoupdate.SetTooltipText("Should URTrator check for updates and update itself? Not working now.") autoupdate_label := gtk.NewLabel("Automatically update URTrator?")
general_vbox.PackStart(o.autoupdate, false, true, 5) 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")) o.tab_widget.AppendPage(general_vbox, gtk.NewLabel("General"))
} }
@@ -176,7 +194,7 @@ func (o *OptionsDialog) initializeTabs() {
// Buttons for saving and discarding changes. // Buttons for saving and discarding changes.
buttons_hbox := gtk.NewHBox(false, 0) buttons_hbox := gtk.NewHBox(false, 0)
sep := gtk.NewHSeparator() sep := gtk.NewHBox(false, 0)
cancel_button := gtk.NewButtonWithLabel("Cancel") cancel_button := gtk.NewButtonWithLabel("Cancel")
cancel_button.Clicked(o.closeOptionsDialogByCancel) cancel_button.Clicked(o.closeOptionsDialogByCancel)
@@ -195,7 +213,7 @@ func (o *OptionsDialog) initializeTabs() {
} }
func (o *OptionsDialog) initializeUrtTab() { func (o *OptionsDialog) initializeUrtTab() {
urt_hbox := gtk.NewHBox(false, 0) urt_hbox := gtk.NewHBox(false, 5)
// Profiles list. // Profiles list.
o.profiles_list = gtk.NewTreeView() 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("Profile name", gtk.NewCellRendererText(), "text", 0))
o.profiles_list.AppendColumn(gtk.NewTreeViewColumnWithAttributes("Urban Terror version", gtk.NewCellRendererText(), "text", 1)) 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. // Profiles list buttons.
urt_profiles_buttons_vbox := gtk.NewVBox(false, 0) urt_profiles_buttons_vbox := gtk.NewVBox(false, 0)
button_add := gtk.NewButtonWithLabel("Add") button_add := gtk.NewButtonWithLabel("Add")
button_add.SetTooltipText("Add new profile") button_add.SetTooltipText("Add new profile")
button_add.Clicked(o.addProfile) 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 := gtk.NewButtonWithLabel("Edit")
button_edit.SetTooltipText("Edit selected profile. Do nothing if no profile was selected.") 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) urt_profiles_buttons_vbox.PackStart(button_edit, false, true, 5)
// Spacer for profiles list buttons. // Spacer for profiles list buttons.
sep := gtk.NewVSeparator() sep := gtk.NewVBox(false, 0)
urt_profiles_buttons_vbox.PackStart(sep, true, true, 5) urt_profiles_buttons_vbox.PackStart(sep, true, true, 5)
button_delete := gtk.NewButtonWithLabel("Delete") button_delete := gtk.NewButtonWithLabel("Delete")
button_delete.SetTooltipText("Delete selected profile. Do nothing if no profile was selected.") button_delete.SetTooltipText("Delete selected profile. Do nothing if no profile was selected.")
button_delete.Clicked(o.deleteProfile) 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) urt_hbox.Add(urt_profiles_buttons_vbox)

View File

@@ -27,8 +27,8 @@ import (
type OptionsProfile struct { type OptionsProfile struct {
// Window. // Window.
window *gtk.Window window *gtk.Window
// Main Vertical Box. // Main table.
vbox *gtk.VBox table *gtk.Table
// Profile name. // Profile name.
profile_name *gtk.Entry profile_name *gtk.Entry
// Binary path. // Binary path.
@@ -148,90 +148,85 @@ func (op *OptionsProfile) Initialize(update bool) {
op.window.SetPosition(gtk.WIN_POS_CENTER) op.window.SetPosition(gtk.WIN_POS_CENTER)
op.window.SetIcon(logo) 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.
profile_name_tooltip := "This how you will see profile on profiles lists." 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 := gtk.NewLabel("Profile name:")
pn_label.SetTooltipText(profile_name_tooltip) pn_label.SetTooltipText(profile_name_tooltip)
profile_name_sep := gtk.NewHSeparator() pn_label.SetAlignment(0, 0)
profile_name_sep.SetTooltipText(profile_name_tooltip) op.table.Attach(pn_label, 0, 1, 0, 1, gtk.FILL, gtk.SHRINK, 5, 5)
op.profile_name = gtk.NewEntry() op.profile_name = gtk.NewEntry()
op.profile_name.SetTooltipText(profile_name_tooltip) op.profile_name.SetTooltipText(profile_name_tooltip)
pn_hbox.PackStart(pn_label, false, true, 5) op.table.Attach(op.profile_name, 1, 2, 0, 1, gtk.FILL, gtk.FILL, 5, 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)
// Urban Terror version. // Urban Terror version.
urt_version_tooltip := "Urban Terror version for which this profile applies." 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 := gtk.NewLabel("Urban Terror version:")
urt_version_label.SetTooltipText(urt_version_tooltip) urt_version_label.SetTooltipText(urt_version_tooltip)
urt_version_sep := gtk.NewHSeparator() urt_version_label.SetAlignment(0, 0)
urt_version_sep.SetTooltipText(urt_version_tooltip) 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 = gtk.NewComboBoxText()
op.urt_version_combo.SetTooltipText(urt_version_tooltip) op.urt_version_combo.SetTooltipText(urt_version_tooltip)
op.urt_version_combo.AppendText("4.2.023") op.urt_version_combo.AppendText("4.2.023")
op.urt_version_combo.AppendText("4.3.0") op.urt_version_combo.AppendText("4.3.0")
op.urt_version_combo.AppendText("4.3.1") op.urt_version_combo.AppendText("4.3.1")
op.urt_version_combo.SetActive(2) op.urt_version_combo.SetActive(2)
urt_version_hbox.PackStart(urt_version_label, false, true, 5) op.table.Attach(op.urt_version_combo, 1, 2, 1, 2, gtk.FILL, gtk.FILL, 5, 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)
// Urban Terror binary path. // 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" 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_hbox := gtk.NewHBox(false, 0)
binpath_label := gtk.NewLabel("Urban Terror binary:") binpath_label := gtk.NewLabel("Urban Terror binary:")
binpath_label.SetTooltipText(select_binary_tooltip) binpath_label.SetTooltipText(select_binary_tooltip)
binpath_sep := gtk.NewHSeparator() binpath_label.SetAlignment(0, 0)
binpath_sep.SetTooltipText(select_binary_tooltip) op.table.Attach(binpath_label, 0, 1, 2, 3, gtk.FILL, gtk.SHRINK, 5, 5)
op.binary_path = gtk.NewEntry() op.binary_path = gtk.NewEntry()
op.binary_path.SetTooltipText(select_binary_tooltip) op.binary_path.SetTooltipText(select_binary_tooltip)
button_select_binary := gtk.NewButtonWithLabel("Browse") button_select_binary := gtk.NewButtonWithLabel("Browse")
button_select_binary.SetTooltipText(select_binary_tooltip) button_select_binary.SetTooltipText(select_binary_tooltip)
button_select_binary.Clicked(op.browseForBinary) 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(op.binary_path, true, true, 5)
binpath_hbox.PackStart(button_select_binary, false, 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? // 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." 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.another_x_session.SetTooltipText(another_x_tooltip)
op.vbox.PackStart(op.another_x_session, false, true, 5) // macOS and Windows can't do that :).
// macOS can't do that :).
if runtime.GOOS != "linux" { if runtime.GOOS != "linux" {
op.another_x_session.SetSensitive(false) 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. // Additional game parameters.
params_tooltip := "Additional parameters that will be passed to Urban Terror executable." 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 := gtk.NewLabel("Additional parameters:")
params_label.SetTooltipText(params_tooltip) params_label.SetTooltipText(params_tooltip)
params_sep := gtk.NewHSeparator() params_label.SetAlignment(0, 0)
params_sep.SetTooltipText(params_tooltip) op.table.Attach(params_label, 0, 1, 4, 5, gtk.FILL, gtk.SHRINK, 5, 5)
op.additional_parameters = gtk.NewEntry() op.additional_parameters = gtk.NewEntry()
op.additional_parameters.SetTooltipText(params_tooltip) op.additional_parameters.SetTooltipText(params_tooltip)
params_hbox.PackStart(params_label, false, true, 5) op.table.Attach(op.additional_parameters, 1, 2, 4, 5, gtk.FILL, gtk.FILL, 5, 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)
// Vertical separator. // Invisible thing.
vert_sep := gtk.NewVSeparator() inv_label := gtk.NewLabel("")
op.vbox.PackStart(vert_sep, true, true, 5) op.table.Attach(inv_label, 1, 2, 5, 6, gtk.EXPAND, gtk.FILL, 5, 5)
// The buttons. // The buttons.
buttons_box := gtk.NewHBox(false, 0) buttons_box := gtk.NewHBox(false, 0)
buttons_sep := gtk.NewHSeparator() buttons_sep := gtk.NewHBox(false, 0)
cancel_button := gtk.NewButtonWithLabel("Cancel") cancel_button := gtk.NewButtonWithLabel("Cancel")
cancel_button.SetTooltipText("Close without saving") cancel_button.SetTooltipText("Close without saving")
@@ -251,9 +246,14 @@ func (op *OptionsProfile) Initialize(update bool) {
add_button.Clicked(op.saveProfile) add_button.Clicked(op.saveProfile)
buttons_box.PackStart(add_button, false, true, 5) 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() op.window.ShowAll()
} }
@@ -262,26 +262,23 @@ func (op *OptionsProfile) InitializeUpdate(profile_name string) {
op.Initialize(true) op.Initialize(true)
// Get profile data. // Get profile data.
profile := []datamodels.Profile{} profile := ctx.Cache.Profiles[profile_name].Profile
err := ctx.Database.Db.Select(&profile, ctx.Database.Db.Rebind("SELECT * FROM urt_profiles WHERE name=?"), profile_name) op.profile_name.SetText(profile.Name)
if err != nil { op.binary_path.SetText(profile.Binary)
fmt.Println(err.Error()) op.additional_parameters.SetText(profile.Additional_params)
} if profile.Second_x_session == "1" {
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" {
op.another_x_session.SetActive(true) 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) op.urt_version_combo.SetActive(1)
} else if profile.Version == "4.3.1" {
op.urt_version_combo.SetActive(2)
} else { } else {
op.urt_version_combo.SetActive(0) op.urt_version_combo.SetActive(0)
} }
op.old_profile = &profile[0] op.old_profile = profile
} }

104
ui/server_cvars.go Normal file
View 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)
}

View File

@@ -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...")
}