macOS fixes for profiles and launching. Version bump.

More fixes here. First, fixed binary path parsing for profiles,
so you should be able to add a profile on macOS now. Only one
requirement - you should add Quake3-UrT.x86_64 file, which located
inside Urban Terror's application bundle, under Contents/MacOS
directory.

Fixed the way we call Urban Terror on macOS and tested it. Should
work now flawlessly.

Bumped to 0.1.0-beta2, and mac-only release for now.
This commit is contained in:
Stanislav Nikitin 2016-10-09 17:06:47 +05:00
parent eaffb1f1ab
commit df4d6a3cca
5 changed files with 35 additions and 12 deletions

3
.gitignore vendored
View File

@ -1,3 +1,6 @@
# We don't need binaries.
urtrator
*tar*
# macOS things
.DS_Store

View File

@ -10,5 +10,5 @@
package common
const (
URTRATOR_VERSION = "0.1-beta1"
URTRATOR_VERSION = "0.1-beta2"
)

2
doc/installation/macos/make-app.sh Normal file → Executable file
View File

@ -32,7 +32,7 @@ if [ $? -ne 0 ]; then
fi
echo "Building URTrator..."
go build -v github.com/pztrn/urtrator
go install -v github.com/pztrn/urtrator
if [ $? -ne 0 ]; then
echo "Failed to build URTrator! Please, create a new bug report at https://github.com/pztrn/urtrator and attach FULL console output!"
exit 1

View File

@ -15,6 +15,7 @@ import (
"fmt"
"os"
"os/exec"
"runtime"
"strconv"
"strings"
@ -88,8 +89,7 @@ func (l *Launcher) Launch(server_profile *datamodels.Server, user_profile *datam
launch_params = append(launch_params, additional_parameters[i])
}
}
if user_profile.Second_x_session == "1" {
fmt.Println(launch_params)
if runtime.GOOS == "linux" && user_profile.Second_x_session == "1" {
launch_params = append([]string{launch_bin}, launch_params...)
display := l.findFreeDisplay()
launch_bin, err = exec.LookPath("xinit")
@ -98,7 +98,15 @@ func (l *Launcher) Launch(server_profile *datamodels.Server, user_profile *datam
}
launch_params = append(launch_params, "--", ":" + display)
}
fmt.Println(launch_params)
if runtime.GOOS == "darwin" {
// On macOS we should not start binary, but application bundle.
// So we will obtain app bundle path.
bundle_path := strings.Split(launch_bin, "/Contents")[0]
// and create special launch string, which involves open.
launch_bin = "/usr/bin/open"
launch_params = append([]string{launch_bin, "-W", bundle_path, "--args"}, launch_params...)
}
fmt.Println(launch_bin, launch_params)
go func() {
go func() {
cmd := exec.Command(launch_bin, launch_params...)

View File

@ -53,7 +53,7 @@ type OptionsProfile struct {
}
func (op *OptionsProfile) browseForBinary() {
op.f = gtk.NewFileChooserDialog("URTrator - Select Urban Terro binary", op.window, gtk.FILE_CHOOSER_ACTION_OPEN, gtk.STOCK_OK, gtk.RESPONSE_ACCEPT)
op.f = gtk.NewFileChooserDialog("URTrator - Select Urban Terror binary", op.window, gtk.FILE_CHOOSER_ACTION_OPEN, gtk.STOCK_OK, gtk.RESPONSE_ACCEPT)
op.f.Response(op.browseForBinaryHelper)
op.f.Run()
}
@ -62,6 +62,7 @@ func (op *OptionsProfile) browseForBinaryHelper() {
filename := op.f.GetFilename()
op.binary_path.SetText(filename)
op.f.Destroy()
fmt.Println(filename)
// Check for valid filename.
// ToDo: add more OSes.
@ -80,16 +81,27 @@ func (op *OptionsProfile) browseForBinaryHelper() {
}
}
} else if runtime.GOOS == "darwin" {
// No separate arch thing here, macOS now 64bit only.
if len(filename) > 0 && strings.Split(filename, ".")[1] != "x86_64" && strings.Split(filename, ".")[0] != "Quake3-UrT" {
fmt.Println("Invalid binary selected!")
mbox_string := "Invalid binary selected!\nAccording to your OS, it should be Quake3-UrT.app/Contents/MacOS/Quake3-UrT.x86_64."
// Official application: Quake3-UrT.app. Split by it and get second
// part of string.
if strings.Contains(filename, "Quake3-UrT.app") {
filename = strings.Split(filename, "Quake3-UrT.app")[1]
if len(filename) > 0 && !strings.Contains(strings.Split(filename, ".")[1], "x86_64") && !strings.Contains(strings.Split(filename, ".")[0], "Quake3-UrT") {
fmt.Println("Invalid binary selected!")
mbox_string := "Invalid binary selected!\nAccording to your OS, it should be Quake3-UrT.app/Contents/MacOS/Quake3-UrT.x86_64."
m := gtk.NewMessageDialog(op.window, gtk.DIALOG_MODAL, gtk.MESSAGE_ERROR, gtk.BUTTONS_OK, mbox_string)
m.Response(func() {
m.Destroy()
})
m.Run()
op.binary_path.SetText("")
}
} else {
mbox_string := "Invalid binary selected!\nAccording to your OS, it should be Quake3-UrT.app/Contents/MacOS/Quake3-UrT.x86_64.\n\nNote, that currently URTrator supports only official binary."
m := gtk.NewMessageDialog(op.window, gtk.DIALOG_MODAL, gtk.MESSAGE_ERROR, gtk.BUTTONS_OK, mbox_string)
m.Response(func() {
m.Destroy()
})
m.Run()
op.binary_path.SetText("")
}
}
}
@ -177,7 +189,7 @@ func (op *OptionsProfile) Initialize(update bool) {
op.another_x_session.SetTooltipText(another_x_tooltip)
op.vbox.PackStart(op.another_x_session, false, true, 5)
// macOS can't do that :).
if runtime.GOOS == "darwin" {
if runtime.GOOS != "linux" {
op.another_x_session.SetSensitive(false)
}