Compare commits
11 Commits
v0.1.0-bet
...
v0.1.0-bet
| Author | SHA1 | Date | |
|---|---|---|---|
| e731653652 | |||
| e16d6fa878 | |||
| 89298d894b | |||
| 88b9b31f6a | |||
| 1fe49871f1 | |||
| 4f5bf90dbe | |||
| 25bebf87df | |||
| c4ed421106 | |||
| 0c0fcd5b24 | |||
| 4d466a9d2b | |||
| 2cdee94efe |
@@ -25,6 +25,7 @@ the game.
|
|||||||
* Favorites servers.
|
* Favorites servers.
|
||||||
* Updating single server.
|
* Updating single server.
|
||||||
* Showing information about servers (like in UrT Connector).
|
* Showing information about servers (like in UrT Connector).
|
||||||
|
* Clipboard monitoring.
|
||||||
|
|
||||||
Planning:
|
Planning:
|
||||||
|
|
||||||
@@ -35,11 +36,15 @@ Planning:
|
|||||||
* All kinds of notifications.
|
* All kinds of notifications.
|
||||||
* Extended profile editor, so every profile could have own configuration
|
* Extended profile editor, so every profile could have own configuration
|
||||||
files, etc.
|
files, etc.
|
||||||
* Clipboard monitoring.
|
|
||||||
* ...maybe more :)
|
* ...maybe more :)
|
||||||
|
|
||||||
# Installation
|
# Installation
|
||||||
|
|
||||||
|
## Precautions
|
||||||
|
|
||||||
|
Due to Go's GC bugs, it is required to use devel version of Go
|
||||||
|
compiler!
|
||||||
|
|
||||||
## Release
|
## Release
|
||||||
|
|
||||||
You don't need to install anything, thanks to Go's.
|
You don't need to install anything, thanks to Go's.
|
||||||
|
|||||||
@@ -21,8 +21,28 @@ type Colorizer struct {
|
|||||||
colors map[string]string
|
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 {
|
func (c *Colorizer) Fix(data string) string {
|
||||||
result := ""
|
var result string = ""
|
||||||
|
|
||||||
data = html.EscapeString(data)
|
data = html.EscapeString(data)
|
||||||
|
|
||||||
|
|||||||
@@ -10,5 +10,5 @@
|
|||||||
package common
|
package common
|
||||||
|
|
||||||
const (
|
const (
|
||||||
URTRATOR_VERSION = "0.1-beta4"
|
URTRATOR_VERSION = "0.1-beta5"
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -440,7 +440,18 @@ 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.
|
// 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.
|
||||||
|
// 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.
|
// Selection changed signal, which will update server's short info pane.
|
||||||
m.all_servers.Connect("cursor-changed", m.showShortServerInformation)
|
m.all_servers.Connect("cursor-changed", m.showShortServerInformation)
|
||||||
@@ -454,8 +465,15 @@ func (m *MainWindow) InitializeTabs() {
|
|||||||
m.all_servers_hide_offline.SetTooltipText("Hide offline servers on Servers tab")
|
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)
|
tab_all_srv_ctl_vbox.PackStart(m.all_servers_hide_offline, false, true, 5)
|
||||||
m.all_servers_hide_offline.Clicked(m.hideOfflineAllServers)
|
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)
|
m.all_servers_hide_offline.SetActive(true)
|
||||||
|
} else {
|
||||||
|
if all_servers_hide_offline_cb_val == "1" {
|
||||||
|
m.all_servers_hide_offline.SetActive(true)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Final separator.
|
// Final separator.
|
||||||
@@ -493,7 +511,11 @@ func (m *MainWindow) InitializeTabs() {
|
|||||||
width_int, _ := strconv.Atoi(width)
|
width_int, _ := strconv.Atoi(width)
|
||||||
|
|
||||||
col := gtk.NewTreeViewColumnWithAttributes(name, gtk.NewCellRendererText(), "markup", position_int)
|
col := gtk.NewTreeViewColumnWithAttributes(name, gtk.NewCellRendererText(), "markup", position_int)
|
||||||
col.SetSortColumnId(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.SetReorderable(true)
|
||||||
col.SetResizable(true)
|
col.SetResizable(true)
|
||||||
// GtkTreeViewColumn.SetFixedWidth() accepts only positive integers.
|
// GtkTreeViewColumn.SetFixedWidth() accepts only positive integers.
|
||||||
@@ -524,8 +546,15 @@ func (m *MainWindow) InitializeTabs() {
|
|||||||
m.fav_servers_hide_offline.SetTooltipText("Hide offline servers on Favorites tab")
|
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)
|
tab_fav_srv_ctl_vbox.PackStart(m.fav_servers_hide_offline, false, true, 5)
|
||||||
m.fav_servers_hide_offline.Clicked(m.hideOfflineFavoriteServers)
|
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)
|
m.fav_servers_hide_offline.SetActive(true)
|
||||||
|
} else {
|
||||||
|
if favorite_servers_hide_offline_cb_val == "1" {
|
||||||
|
m.fav_servers_hide_offline.SetActive(true)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Final separator.
|
// Final separator.
|
||||||
@@ -572,7 +601,7 @@ func (m *MainWindow) InitializeToolbar() {
|
|||||||
fav_button_icon_pixbuf.SetSize(24, 24)
|
fav_button_icon_pixbuf.SetSize(24, 24)
|
||||||
fav_button_icon_pixbuf.Write(fav_button_icon_bytes)
|
fav_button_icon_pixbuf.Write(fav_button_icon_bytes)
|
||||||
fav_button_icon := gtk.NewImageFromPixbuf(fav_button_icon_pixbuf.GetPixbuf())
|
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.SetTooltipText("Add selected server to favorites")
|
||||||
fav_button.OnClicked(m.addToFavorites)
|
fav_button.OnClicked(m.addToFavorites)
|
||||||
m.toolbar.Insert(fav_button, 3)
|
m.toolbar.Insert(fav_button, 3)
|
||||||
|
|||||||
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 := ctx.Colorizer.ClearFromMarkup(name1_raw.GetString())
|
||||||
|
name2 := 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
|
||||||
|
}
|
||||||
@@ -177,7 +177,7 @@ func (op *OptionsProfile) Initialize(update bool) {
|
|||||||
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(1)
|
op.urt_version_combo.SetActive(2)
|
||||||
urt_version_hbox.PackStart(urt_version_label, false, true, 5)
|
urt_version_hbox.PackStart(urt_version_label, false, true, 5)
|
||||||
urt_version_hbox.PackStart(urt_version_sep, true, true, 5)
|
urt_version_hbox.PackStart(urt_version_sep, true, true, 5)
|
||||||
urt_version_hbox.PackStart(op.urt_version_combo, true, true, 5)
|
urt_version_hbox.PackStart(op.urt_version_combo, true, true, 5)
|
||||||
|
|||||||
Reference in New Issue
Block a user