Optimize lobby screen
This commit is contained in:
parent
475bae8664
commit
32ab7da9af
|
@ -0,0 +1,18 @@
|
|||
// +build !js !wasm
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"flag"
|
||||
|
||||
"code.rocketnine.space/tslocum/boxcars/game"
|
||||
)
|
||||
|
||||
func parseFlags(g *game.Game) {
|
||||
flag.StringVar(&g.Username, "username", "", "Username")
|
||||
flag.StringVar(&g.Password, "password", "", "Password")
|
||||
flag.StringVar(&g.ServerAddress, "address", "fibs.com:4321", "Server address")
|
||||
flag.BoolVar(&g.Watch, "watch", false, "Watch random game")
|
||||
flag.BoolVar(&g.TV, "tv", false, "Watch random games continuously")
|
||||
flag.Parse()
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
// +build js,wasm
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"code.rocketnine.space/tslocum/boxcars/game"
|
||||
)
|
||||
|
||||
func parseFlags(g *game.Game) {
|
||||
// Do nothing
|
||||
}
|
89
game/game.go
89
game/game.go
|
@ -9,6 +9,8 @@ import (
|
|||
_ "image/png"
|
||||
"log"
|
||||
"os"
|
||||
"path"
|
||||
"runtime/pprof"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
|
@ -42,6 +44,8 @@ var assetsFS embed.FS
|
|||
|
||||
var debugExtra []byte
|
||||
|
||||
var debugGame *Game
|
||||
|
||||
var (
|
||||
imgCheckerWhite *ebiten.Image
|
||||
imgCheckerBlack *ebiten.Image
|
||||
|
@ -161,6 +165,10 @@ type Game struct {
|
|||
keyboard *kibodo.Keyboard
|
||||
shownKeyboard bool
|
||||
|
||||
buffers *tabbedBuffers
|
||||
|
||||
cpuProfile *os.File
|
||||
|
||||
op *ebiten.DrawImageOptions
|
||||
}
|
||||
|
||||
|
@ -178,17 +186,31 @@ func NewGame() *Game {
|
|||
runeBuffer: make([]rune, 24),
|
||||
|
||||
keyboard: kibodo.NewKeyboard(),
|
||||
|
||||
buffers: newTabbedBuffers(),
|
||||
}
|
||||
g.keyboard.SetKeys(kibodo.KeysQWERTY)
|
||||
|
||||
// TODO
|
||||
go func() {
|
||||
/*
|
||||
time.Sleep(5 * time.Second)
|
||||
g.lobby.offset += 10
|
||||
g.lobby.bufferDirty = true
|
||||
g.toggleProfiling()
|
||||
g.lobby.drawBuffer()
|
||||
g.toggleProfiling()
|
||||
os.Exit(0)
|
||||
*/
|
||||
|
||||
t := time.NewTicker(time.Second / 4)
|
||||
for range t.C {
|
||||
|
||||
_ = g.update()
|
||||
}
|
||||
}()
|
||||
|
||||
debugGame = g // TODO
|
||||
return g
|
||||
}
|
||||
|
||||
|
@ -272,6 +294,13 @@ func (g *Game) Update() error { // Called by ebiten only when input occurs
|
|||
g.pendingWho = nil
|
||||
}
|
||||
|
||||
if ebiten.IsKeyPressed(ebiten.KeyControl) && inpututil.IsKeyJustPressed(ebiten.KeyP) {
|
||||
err = g.toggleProfiling()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
err = g.keyboard.Update()
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to update virtual keyboard: %s", err)
|
||||
|
@ -400,6 +429,8 @@ http://www.fibs.com/help.html#register`
|
|||
} else {
|
||||
// Game board screen
|
||||
g.Board.draw(screen)
|
||||
|
||||
g.buffers.draw(screen)
|
||||
}
|
||||
|
||||
if g.Debug > 0 {
|
||||
|
@ -447,6 +478,36 @@ func (g *Game) Layout(outsideWidth, outsideHeight int) (int, int) {
|
|||
g.lobby.setRect(0, 0, g.screenW, g.screenH)
|
||||
g.Board.setRect(0, 0, g.screenW, g.screenH)
|
||||
|
||||
// Clamp buffer position.
|
||||
bx, by := g.buffers.x, g.buffers.y
|
||||
var bw, bh int
|
||||
if g.buffers.w == 0 && g.buffers.h == 0 {
|
||||
// Set initial buffer position.
|
||||
bx = g.screenW / 2
|
||||
by = g.screenH / 2
|
||||
// Set initial buffer size.
|
||||
bw = g.screenW / 2
|
||||
bh = g.screenH / 4
|
||||
} else {
|
||||
// Scale existing buffer size
|
||||
bx, by = bx*(outsideWidth/g.screenW), by*(outsideHeight/g.screenH)
|
||||
bw, bh = g.buffers.w*(outsideWidth/g.screenW), g.buffers.h*(outsideHeight/g.screenH)
|
||||
if bw < 200 {
|
||||
bw = 200
|
||||
}
|
||||
if bh < 100 {
|
||||
bh = 100
|
||||
}
|
||||
}
|
||||
padding := 7
|
||||
if bx > g.screenW-padding {
|
||||
bx = g.screenW - padding
|
||||
}
|
||||
if by > g.screenH-padding {
|
||||
by = g.screenH - padding
|
||||
}
|
||||
g.buffers.setRect(bx, by, bw, bh)
|
||||
|
||||
displayArea := 200
|
||||
g.keyboard.SetRect(0, displayArea, g.screenW, g.screenH-displayArea)
|
||||
return outsideWidth, outsideHeight
|
||||
|
@ -456,6 +517,34 @@ func (g *Game) resetImageOptions() {
|
|||
g.op.GeoM.Reset()
|
||||
}
|
||||
|
||||
func (g *Game) toggleProfiling() error {
|
||||
if g.cpuProfile == nil {
|
||||
log.Println("Profiling started...")
|
||||
|
||||
homeDir, err := os.UserHomeDir()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
g.cpuProfile, err = os.Create(path.Join(homeDir, "cpu.prof")) // TODO add flag
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := pprof.StartCPUProfile(g.cpuProfile); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
pprof.StopCPUProfile()
|
||||
g.cpuProfile.Close()
|
||||
g.cpuProfile = nil
|
||||
|
||||
log.Println("Profiling stopped")
|
||||
return nil
|
||||
}
|
||||
|
||||
func (g *Game) Exit() {
|
||||
g.Board.drawFrame <- false
|
||||
os.Exit(0)
|
||||
|
|
104
game/lobby.go
104
game/lobby.go
|
@ -51,6 +51,9 @@ type lobby struct {
|
|||
buffer *ebiten.Image
|
||||
bufferDirty bool
|
||||
|
||||
bufferButtons *ebiten.Image
|
||||
bufferButtonsDirty bool
|
||||
|
||||
op *ebiten.DrawImageOptions
|
||||
|
||||
c *fibs.Client
|
||||
|
@ -79,6 +82,41 @@ func (l *lobby) getButtons() []*lobbyButton {
|
|||
return mainButtons
|
||||
}
|
||||
|
||||
func (l *lobby) _drawBufferButtons() {
|
||||
l.bufferButtons.Fill(frameColor)
|
||||
|
||||
// Draw border
|
||||
for ly := 0; ly < 2; ly++ {
|
||||
for lx := 0; lx < l.w; lx++ {
|
||||
l.bufferButtons.Set(lx, ly, triangleA)
|
||||
}
|
||||
}
|
||||
|
||||
buttons := l.getButtons()
|
||||
|
||||
buttonWidth := l.w / len(buttons)
|
||||
for i, button := range buttons {
|
||||
// Draw border
|
||||
if i > 0 {
|
||||
for ly := 0; ly < l.buttonBarHeight; ly++ {
|
||||
for lx := buttonWidth * i; lx < (buttonWidth*i)+2; lx++ {
|
||||
l.bufferButtons.Set(lx, ly, triangleA)
|
||||
}
|
||||
}
|
||||
}
|
||||
bounds := text.BoundString(mplusNormalFont, button.label)
|
||||
|
||||
labelColor := triangleA
|
||||
|
||||
img := ebiten.NewImage(bounds.Dx()*2, bounds.Dy()*2)
|
||||
text.Draw(img, button.label, mplusNormalFont, 0, bounds.Dy(), labelColor)
|
||||
|
||||
l.op.GeoM.Reset()
|
||||
l.op.GeoM.Translate(float64(buttonWidth*i)+float64((buttonWidth-bounds.Dx())/2), float64(l.buttonBarHeight-bounds.Dy())/2-float64(bounds.Dy()/2))
|
||||
l.bufferButtons.DrawImage(img, l.op)
|
||||
}
|
||||
}
|
||||
|
||||
// Draw to the off-screen buffer.
|
||||
func (l *lobby) drawBuffer() {
|
||||
l.buffer.Fill(frameColor)
|
||||
|
@ -172,43 +210,14 @@ func (l *lobby) drawBuffer() {
|
|||
}
|
||||
}
|
||||
|
||||
// Fill button bar
|
||||
for ly := 0; ly < l.buttonBarHeight; ly++ {
|
||||
for lx := 0; lx < l.w; lx++ {
|
||||
l.buffer.Set(lx, l.h-ly, frameColor)
|
||||
}
|
||||
if l.bufferButtonsDirty {
|
||||
l._drawBufferButtons()
|
||||
l.bufferButtonsDirty = false
|
||||
}
|
||||
|
||||
// Draw border
|
||||
for ly := l.h - l.buttonBarHeight; ly < l.h-l.buttonBarHeight+2; ly++ {
|
||||
for lx := 0; lx < l.w; lx++ {
|
||||
l.buffer.Set(lx, ly, triangleA)
|
||||
}
|
||||
}
|
||||
|
||||
buttons := l.getButtons()
|
||||
|
||||
buttonWidth := l.w / len(buttons)
|
||||
for i, button := range buttons {
|
||||
// Draw border
|
||||
if i > 0 {
|
||||
for ly := l.h - l.buttonBarHeight; ly < l.h; ly++ {
|
||||
for lx := buttonWidth * i; lx < (buttonWidth*i)+2; lx++ {
|
||||
l.buffer.Set(lx, ly, triangleA)
|
||||
}
|
||||
}
|
||||
}
|
||||
bounds := text.BoundString(mplusNormalFont, button.label)
|
||||
|
||||
labelColor := triangleA
|
||||
|
||||
img := ebiten.NewImage(bounds.Dx()*2, bounds.Dy()*2)
|
||||
text.Draw(img, button.label, mplusNormalFont, 0, bounds.Dy(), labelColor)
|
||||
|
||||
l.op.GeoM.Reset()
|
||||
l.op.GeoM.Translate(float64(buttonWidth*i)+float64((buttonWidth-bounds.Dx())/2), float64(l.h-l.buttonBarHeight)+float64(l.buttonBarHeight-bounds.Dy())/2-float64(bounds.Dy()/2))
|
||||
l.buffer.DrawImage(img, l.op)
|
||||
}
|
||||
l.op.GeoM.Reset()
|
||||
l.op.GeoM.Translate(float64(l.x), float64(l.h-l.buttonBarHeight))
|
||||
l.buffer.DrawImage(l.bufferButtons, l.op)
|
||||
}
|
||||
|
||||
// Draw to the screen.
|
||||
|
@ -217,7 +226,14 @@ func (l *lobby) draw(screen *ebiten.Image) {
|
|||
return
|
||||
}
|
||||
|
||||
var p bool
|
||||
|
||||
if l.bufferDirty {
|
||||
if len(l.who) > 1 {
|
||||
p = true
|
||||
//debugGame.toggleProfiling()
|
||||
}
|
||||
|
||||
l.drawBuffer()
|
||||
l.bufferDirty = false
|
||||
}
|
||||
|
@ -225,6 +241,11 @@ func (l *lobby) draw(screen *ebiten.Image) {
|
|||
l.op.GeoM.Reset()
|
||||
l.op.GeoM.Translate(float64(l.x), float64(l.y))
|
||||
screen.DrawImage(l.buffer, l.op)
|
||||
|
||||
if p {
|
||||
//debugGame.toggleProfiling()
|
||||
//os.Exit(0)
|
||||
}
|
||||
}
|
||||
|
||||
func (l *lobby) setRect(x, y, w, h int) {
|
||||
|
@ -232,17 +253,19 @@ func (l *lobby) setRect(x, y, w, h int) {
|
|||
return
|
||||
}
|
||||
|
||||
if l.w != w || l.h != h {
|
||||
l.buffer = ebiten.NewImage(w, h)
|
||||
}
|
||||
|
||||
s := ebiten.DeviceScaleFactor()
|
||||
l.padding = 4 * s
|
||||
l.entryH = 32 * s
|
||||
l.buttonBarHeight = int(200 * s)
|
||||
|
||||
if l.w != w || l.h != h {
|
||||
l.buffer = ebiten.NewImage(w, h)
|
||||
l.bufferButtons = ebiten.NewImage(w, l.buttonBarHeight)
|
||||
}
|
||||
|
||||
l.x, l.y, l.w, l.h = x, y, w, h
|
||||
l.bufferDirty = true
|
||||
l.bufferButtonsDirty = true
|
||||
}
|
||||
|
||||
func (l *lobby) click(x, y int) {
|
||||
|
@ -268,6 +291,7 @@ func (l *lobby) click(x, y int) {
|
|||
|
||||
l.inviteUser = nil
|
||||
l.bufferDirty = true
|
||||
l.bufferButtonsDirty = true
|
||||
|
||||
viewBoard = true
|
||||
case 1:
|
||||
|
@ -282,6 +306,7 @@ func (l *lobby) click(x, y int) {
|
|||
case 3:
|
||||
l.inviteUser = nil
|
||||
l.bufferDirty = true
|
||||
l.bufferButtonsDirty = true
|
||||
}
|
||||
return
|
||||
}
|
||||
|
@ -291,6 +316,7 @@ func (l *lobby) click(x, y int) {
|
|||
l.inviteUser = l.who[l.selected]
|
||||
l.invitePoints = 1
|
||||
l.bufferDirty = true
|
||||
l.bufferButtonsDirty = true
|
||||
case 1:
|
||||
l.c.Out <- []byte(fmt.Sprintf("join %s", l.who[l.selected].Username))
|
||||
viewBoard = true
|
||||
|
|
|
@ -0,0 +1,81 @@
|
|||
package game
|
||||
|
||||
import (
|
||||
"github.com/hajimehoshi/ebiten/v2"
|
||||
)
|
||||
|
||||
const (
|
||||
windowMinimized = iota
|
||||
windowNormal
|
||||
WindowMaximized
|
||||
)
|
||||
|
||||
const windowStartingAlpha = 0.8
|
||||
|
||||
type tabbedBuffers struct {
|
||||
buffers []*textBuffer
|
||||
labels [][]byte
|
||||
|
||||
x, y int
|
||||
w, h int
|
||||
|
||||
unfocusedAlpha float64
|
||||
|
||||
buffer *ebiten.Image
|
||||
bufferDirty bool
|
||||
|
||||
op *ebiten.DrawImageOptions
|
||||
|
||||
state int
|
||||
|
||||
focused bool
|
||||
}
|
||||
|
||||
func newTabbedBuffers() *tabbedBuffers {
|
||||
return &tabbedBuffers{
|
||||
state: windowNormal,
|
||||
unfocusedAlpha: windowStartingAlpha,
|
||||
buffer: ebiten.NewImage(1, 1),
|
||||
op: &ebiten.DrawImageOptions{},
|
||||
}
|
||||
}
|
||||
|
||||
func (t *tabbedBuffers) setRect(x, y, w, h int) {
|
||||
if t.x == x && t.y == y && t.w == w && t.h == h {
|
||||
return
|
||||
}
|
||||
|
||||
if t.w != w || t.h != h {
|
||||
t.buffer = ebiten.NewImage(w, h)
|
||||
t.bufferDirty = true
|
||||
}
|
||||
|
||||
t.x, t.y, t.w, t.h = x, y, w, h
|
||||
}
|
||||
|
||||
func (t *tabbedBuffers) drawBuffer() {
|
||||
t.buffer.Fill(frameColor)
|
||||
}
|
||||
|
||||
func (t *tabbedBuffers) draw(target *ebiten.Image) {
|
||||
if t.buffer == nil {
|
||||
return
|
||||
}
|
||||
return // This feature is not yet finished.
|
||||
|
||||
if t.bufferDirty {
|
||||
t.drawBuffer()
|
||||
t.bufferDirty = false
|
||||
}
|
||||
|
||||
alpha := t.unfocusedAlpha
|
||||
if t.focused {
|
||||
alpha = 1.0
|
||||
}
|
||||
|
||||
t.op.GeoM.Reset()
|
||||
t.op.GeoM.Translate(float64(t.x), float64(t.y))
|
||||
t.op.ColorM.Reset()
|
||||
t.op.ColorM.Scale(1, 1, 1, alpha)
|
||||
target.DrawImage(t.buffer, t.op)
|
||||
}
|
|
@ -0,0 +1,5 @@
|
|||
package game
|
||||
|
||||
type textBuffer struct {
|
||||
content []byte
|
||||
}
|
10
go.mod
10
go.mod
|
@ -5,7 +5,7 @@ go 1.17
|
|||
require (
|
||||
code.rocketnine.space/tslocum/fibs v0.0.0-20211001010223-882585bf240f
|
||||
code.rocketnine.space/tslocum/kibodo v0.0.0-20210917002454-47a7751c7a48
|
||||
github.com/hajimehoshi/ebiten/v2 v2.3.0-alpha.0.20210930150419-0b4bfd471fa9
|
||||
github.com/hajimehoshi/ebiten/v2 v2.2.0
|
||||
github.com/llgcode/draw2d v0.0.0-20210904075650-80aa0a2a901d
|
||||
github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646
|
||||
golang.org/x/image v0.0.0-20210628002857-a66eb6448b8d
|
||||
|
@ -20,10 +20,14 @@ require (
|
|||
github.com/modern-go/reflect2 v1.0.1 // indirect
|
||||
github.com/reiver/go-oi v1.0.0 // indirect
|
||||
github.com/reiver/go-telnet v0.0.0-20180421082511-9ff0b2ab096e // indirect
|
||||
golang.org/x/exp v0.0.0-20210916165020-5cb4fee858ee // indirect
|
||||
golang.org/x/exp v0.0.0-20211012155715-ffe10e552389 // indirect
|
||||
golang.org/x/mobile v0.0.0-20210924032853-1c027f395ef7 // indirect
|
||||
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c // indirect
|
||||
golang.org/x/sys v0.0.0-20210930212924-f542c8878de8 // indirect
|
||||
golang.org/x/sys v0.0.0-20211013075003-97ac67df715c // indirect
|
||||
golang.org/x/text v0.3.7 // indirect
|
||||
nhooyr.io/websocket v1.8.7 // indirect
|
||||
)
|
||||
|
||||
replace code.rocketnine.space/tslocum/fibs => /home/trevor/programming/fibs
|
||||
|
||||
replace code.rocketnine.space/tslocum/kibodo => /home/trevor/programming/kibodo
|
||||
|
|
22
go.sum
22
go.sum
|
@ -1,9 +1,5 @@
|
|||
cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
|
||||
cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
|
||||
code.rocketnine.space/tslocum/fibs v0.0.0-20211001010223-882585bf240f h1:EOB1YJ+7ormKLI/hLweoodN7vqTcEPaCkQfOSQV0ol4=
|
||||
code.rocketnine.space/tslocum/fibs v0.0.0-20211001010223-882585bf240f/go.mod h1:f7Cz0zJWOnJ9DW7R/GTuE8z5XWQtkbXkKpksW9SDu2c=
|
||||
code.rocketnine.space/tslocum/kibodo v0.0.0-20210917002454-47a7751c7a48 h1:iF8WUiUnqJ30k9RgReFSZL2tU+uFhr5Sgld1QqS0rnA=
|
||||
code.rocketnine.space/tslocum/kibodo v0.0.0-20210917002454-47a7751c7a48/go.mod h1:Zd/62u2hSH/wmV//dOi8VhEj31a4IA3c62vGPw/8gZw=
|
||||
dmitri.shuralyov.com/gpu/mtl v0.0.0-20201218220906-28db891af037/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU=
|
||||
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
|
||||
github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=
|
||||
|
@ -131,10 +127,9 @@ github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0/go.mod h1:8NvIoxWQoOIhqOTXgf
|
|||
github.com/grpc-ecosystem/grpc-gateway v1.9.5/go.mod h1:vNeuVxBJEsws4ogUvrchl83t/GYV9WGTSLVdBhOQFDY=
|
||||
github.com/hajimehoshi/bitmapfont/v2 v2.1.3 h1:JefUkL0M4nrdVwVq7MMZxSTh6mSxOylm+C4Anoucbb0=
|
||||
github.com/hajimehoshi/bitmapfont/v2 v2.1.3/go.mod h1:2BnYrkTQGThpr/CY6LorYtt/zEPNzvE/ND69CRTaHMs=
|
||||
github.com/hajimehoshi/ebiten/v2 v2.2.0-alpha.14.0.20210916141036-9c321d1fcf27/go.mod h1:2sY8DHIXNs0Lf/pyTZXltEQtqCKZ2HyXbeUWzrLTlg0=
|
||||
github.com/hajimehoshi/ebiten/v2 v2.3.0-alpha.0.20210930150419-0b4bfd471fa9 h1:UP1Z1UozXrJeTSbMWzmcJ0jWK0PzNOhmrjFMbGg+980=
|
||||
github.com/hajimehoshi/ebiten/v2 v2.3.0-alpha.0.20210930150419-0b4bfd471fa9/go.mod h1:olKl/qqhMBBAm2oI7Zy292nCtE+nitlmYKNF3UpbFn0=
|
||||
github.com/hajimehoshi/file2byteslice v0.0.0-20200812174855-0e5e8a80490e/go.mod h1:CqqAHp7Dk/AqQiwuhV1yT2334qbA/tFWQW0MD2dGqUE=
|
||||
github.com/hajimehoshi/ebiten/v2 v2.2.0-alpha.15.0.20210922174822-263276c5ab11/go.mod h1:z/EEfCcc5el7qM2IfWsaHPkqyThkt1a3Zk+WUGK31Sc=
|
||||
github.com/hajimehoshi/ebiten/v2 v2.2.0 h1:2mP9HrLLqiH9X3MajElYZEjVZU/CGh22iFkjatxhT4w=
|
||||
github.com/hajimehoshi/ebiten/v2 v2.2.0/go.mod h1:olKl/qqhMBBAm2oI7Zy292nCtE+nitlmYKNF3UpbFn0=
|
||||
github.com/hajimehoshi/file2byteslice v0.0.0-20210813153925-5340248a8f41/go.mod h1:CqqAHp7Dk/AqQiwuhV1yT2334qbA/tFWQW0MD2dGqUE=
|
||||
github.com/hajimehoshi/go-mp3 v0.3.2/go.mod h1:qMJj/CSDxx6CGHiZeCgbiq2DSUkbK0UbtXShQcnfyMM=
|
||||
github.com/hajimehoshi/oto v0.6.1/go.mod h1:0QXGEkbuJRohbJaxr7ZQSxnju7hEhseiPx2hrh6raOI=
|
||||
|
@ -349,8 +344,9 @@ golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPh
|
|||
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
|
||||
golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
|
||||
golang.org/x/exp v0.0.0-20190731235908-ec7cb31e5a56/go.mod h1:JhuoJpWY28nO4Vef9tZUw9qufEGTyX1+7lmHxV5q5G4=
|
||||
golang.org/x/exp v0.0.0-20210916165020-5cb4fee858ee h1:qlrAyYdKz4o7rWVUjiKqQJMa4PEpd55fqBU8jpsl4Iw=
|
||||
golang.org/x/exp v0.0.0-20210916165020-5cb4fee858ee/go.mod h1:a3o/VtDNHN+dCVLEpzjjUHOzR+Ln3DHX056ZPzoZGGA=
|
||||
golang.org/x/exp v0.0.0-20211012155715-ffe10e552389 h1:qFfBYVpJAdBCk6Nmd7ZbcyhGmKmv8fps+OyoOfpjvu8=
|
||||
golang.org/x/exp v0.0.0-20211012155715-ffe10e552389/go.mod h1:a3o/VtDNHN+dCVLEpzjjUHOzR+Ln3DHX056ZPzoZGGA=
|
||||
golang.org/x/image v0.0.0-20180708004352-c73c2afc3b81/go.mod h1:ux5Hcp/YLpHSI86hEcLt0YII63i6oz57MZXIpbrjZUs=
|
||||
golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js=
|
||||
golang.org/x/image v0.0.0-20190703141733-d6a02ce849c9/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
|
||||
|
@ -366,6 +362,7 @@ golang.org/x/mobile v0.0.0-20190312151609-d3739f865fa6/go.mod h1:z+o9i4GpDbdi3rU
|
|||
golang.org/x/mobile v0.0.0-20190415191353-3e0bab5405d6/go.mod h1:E/iHnbuqvinMTCcRqshq8CkpyQDoeVncDDYHnLhea+o=
|
||||
golang.org/x/mobile v0.0.0-20201217150744-e6ae53a27f4f/go.mod h1:skQtrUTUwhdJvXM/2KKJzY8pDgNr9I/FOMqDVRPBUS4=
|
||||
golang.org/x/mobile v0.0.0-20210902104108-5d9a33257ab5/go.mod h1:c4YKU3ZylDmvbw+H/PSvm42vhdWbuxCzbonauEAP9B8=
|
||||
golang.org/x/mobile v0.0.0-20210922142229-b5eb1abba0f2/go.mod h1:c4YKU3ZylDmvbw+H/PSvm42vhdWbuxCzbonauEAP9B8=
|
||||
golang.org/x/mobile v0.0.0-20210924032853-1c027f395ef7 h1:CyFUjc175y/mbMjxe+WdqI72jguLyjQChKCDe9mfTvg=
|
||||
golang.org/x/mobile v0.0.0-20210924032853-1c027f395ef7/go.mod h1:c4YKU3ZylDmvbw+H/PSvm42vhdWbuxCzbonauEAP9B8=
|
||||
golang.org/x/mod v0.0.0-20190513183733-4bf6d317e70e/go.mod h1:mXi4GBBbnImb6dmsKGUJ2LatrhH/nqhxcFungHvyanc=
|
||||
|
@ -431,11 +428,10 @@ golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7w
|
|||
golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20210809222454-d867a43fc93e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20210820121016-41cdb8703e55/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20210915083310-ed5796bab164/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20210917161153-d61c044b1678/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20210930212924-f542c8878de8 h1:g54bVHzt/eKaj59LDwiDyLRXbOdJSfwRxA1WYEJx/Yo=
|
||||
golang.org/x/sys v0.0.0-20210930212924-f542c8878de8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20210921065528-437939a70204/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20211013075003-97ac67df715c h1:taxlMj0D/1sOAuv/CbSD+MMDof2vbyPTqz5FNYKpXt8=
|
||||
golang.org/x/sys v0.0.0-20211013075003-97ac67df715c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
|
||||
|
|
8
main.go
8
main.go
|
@ -2,7 +2,6 @@ package main
|
|||
|
||||
import (
|
||||
"bufio"
|
||||
"flag"
|
||||
"log"
|
||||
"os"
|
||||
"os/signal"
|
||||
|
@ -35,12 +34,7 @@ func main() {
|
|||
|
||||
g := game.NewGame()
|
||||
|
||||
flag.StringVar(&g.Username, "username", "", "Username")
|
||||
flag.StringVar(&g.Password, "password", "", "Password")
|
||||
flag.StringVar(&g.ServerAddress, "address", "fibs.com:4321", "Server address")
|
||||
flag.BoolVar(&g.Watch, "watch", false, "Watch random game")
|
||||
flag.BoolVar(&g.TV, "tv", false, "Watch random games continuously")
|
||||
flag.Parse()
|
||||
parseFlags(g)
|
||||
|
||||
if AutoWatch {
|
||||
g.Watch = true
|
||||
|
|
Loading…
Reference in New Issue