Urban Terror launch check on shutdown.

Added checking if Urban Terror launched while trying to shut down
URTrator. If yes - we will show error message and won't quit,
until Urban Terror will be dead.
This commit is contained in:
2016-10-06 22:19:03 +05:00
parent e87d51b1e3
commit ceaaf67510
3 changed files with 42 additions and 5 deletions

View File

@@ -11,6 +11,7 @@ package launcher
import (
// stdlib
"errors"
"fmt"
"os"
"os/exec"
@@ -19,9 +20,30 @@ import (
// local
"github.com/pztrn/urtrator/datamodels"
// Github
"github.com/mattn/go-gtk/gtk"
)
type Launcher struct {}
type Launcher struct {
// Flags.
// Is Urban Terror launched ATM?
launched bool
}
func (l *Launcher) CheckForLaunchedUrbanTerror() error {
if l.launched {
mbox_string := "Game is launched.\n\nCannot quit, because game is launched.\nQuit Urban Terror to exit URTrator!"
m := gtk.NewMessageDialog(nil, gtk.DIALOG_MODAL, gtk.MESSAGE_ERROR, gtk.BUTTONS_OK, mbox_string)
m.Response(func() {
m.Destroy()
})
m.Run()
return errors.New("User didn't select valid profile, mismatch with server's version.")
}
return nil
}
func (l *Launcher) findFreeDisplay() string {
current_display_raw := os.Getenv("DISPLAY")