diff --git a/.gitignore b/.gitignore index 57170e4..0361ac7 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,6 @@ # We don't need binaries. urtrator *tar* + +# macOS things +.DS_Store diff --git a/common/const.go b/common/const.go index fe9da68..47d18f6 100644 --- a/common/const.go +++ b/common/const.go @@ -10,5 +10,5 @@ package common const ( - URTRATOR_VERSION = "0.1-beta1" + URTRATOR_VERSION = "0.1-beta2" ) diff --git a/doc/installation/macos/make-app.sh b/doc/installation/macos/make-app.sh old mode 100644 new mode 100755 index 43fef55..caffbb8 --- a/doc/installation/macos/make-app.sh +++ b/doc/installation/macos/make-app.sh @@ -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 diff --git a/launcher/launcher_object.go b/launcher/launcher_object.go index f9db1af..75bfd4b 100644 --- a/launcher/launcher_object.go +++ b/launcher/launcher_object.go @@ -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...) diff --git a/ui/options_profile.go b/ui/options_profile.go index 46156cc..1fbce2d 100644 --- a/ui/options_profile.go +++ b/ui/options_profile.go @@ -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) }