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.
This commit is contained in:
Stanislav Nikitin 2016-11-26 09:05:48 +05:00
parent 280c65f116
commit bd04870aa3
4 changed files with 64 additions and 46 deletions

View File

@ -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!"

View File

@ -68,8 +68,10 @@ type MainWindow struct {
fav_servers_hide_private *gtk.CheckButton
// 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
@ -92,9 +94,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.
@ -568,9 +573,25 @@ func (m *MainWindow) showHide() {
}
}
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") {
@ -642,15 +663,6 @@ 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>")
// Sorting keys of map.
players_map_keys := make([]string, 0, len(parsed_players_info))
for k := range parsed_players_info {
@ -664,11 +676,13 @@ func (m *MainWindow) showShortServerInformation() {
for k := range players_map_keys {
iter = new(gtk.TreeIter)
nick := ctx.Colorizer.Fix(parsed_players_info[players_map_keys[k]]["nick"])
m.server_info_store.Append(iter)
m.server_info_store.SetValue(iter, 0, nick)
m.server_info_store.SetValue(iter, 1, "(frags: " + parsed_players_info[players_map_keys[k]]["frags"] + " | ping: " + parsed_players_info[players_map_keys[k]]["ping"] + ")")
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)
@ -692,6 +706,7 @@ func (m *MainWindow) showShortServerInformation() {
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]])
}
*/
}
}

View File

@ -84,6 +84,7 @@ func (m *MainWindow) Initialize() {
// Dialogs initialization.
m.options_dialog = &OptionsDialog{}
m.server_cvars_dialog = &ServerCVarsDialog{}
// Main menu.
if runtime.GOOS == "darwin" {
@ -239,6 +240,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.
@ -253,6 +255,33 @@ func (m *MainWindow) initializeSidebar() {
si_scroll.Add(m.server_info)
// 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")
sidebar_vbox.PackStart(quick_connect_frame, false, true, 5)
@ -347,6 +376,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

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