Fix login screen
parent
b98223adfd
commit
210ffa6b22
|
@ -11,7 +11,7 @@ Please share issues and suggestions [here](https://code.rocket9labs.com/tslocum/
|
|||
## Dependencies
|
||||
|
||||
- [ebitengine](https://github.com/hajimehoshi/ebiten) - Game engine
|
||||
- [draw2d](https://github.com/llgcode/draw2d) - Shape drawing
|
||||
- [messeji](https://code.rocket9labs.com/tslocum/messeji) - Text display and input widgets
|
||||
- [kibodo](https://code.rocket9labs.com/tslocum/kibodo) - On-screen keyboard
|
||||
- [draw2d](https://github.com/llgcode/draw2d) - Shape drawing
|
||||
- [resize](https://github.com/nfnt/resize) - Image resizing
|
||||
|
|
2
flags.go
2
flags.go
|
@ -15,6 +15,6 @@ func parseFlags(g *game.Game) {
|
|||
flag.StringVar(&g.ServerAddress, "address", game.DefaultServerAddress, "Server address")
|
||||
flag.BoolVar(&g.Watch, "watch", false, "Watch random game")
|
||||
flag.BoolVar(&g.TV, "tv", false, "Watch random games continuously")
|
||||
flag.IntVar(&g.Debug, "debug", 0, "Print debug information")
|
||||
flag.IntVar(&game.Debug, "debug", 0, "Print debug information")
|
||||
flag.Parse()
|
||||
}
|
||||
|
|
|
@ -64,9 +64,9 @@ func (c *Client) handleWrite() {
|
|||
panic(err)
|
||||
}
|
||||
|
||||
//if debug > 0 {
|
||||
l(fmt.Sprintf("-> %s", split[i]))
|
||||
//}
|
||||
if Debug > 0 {
|
||||
l(fmt.Sprintf("-> %s", split[i]))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -91,9 +91,9 @@ func (c *Client) handleRead() {
|
|||
}
|
||||
c.Events <- ev
|
||||
|
||||
//if debug > 0 {
|
||||
l(fmt.Sprintf("<- %s", msg))
|
||||
//}
|
||||
if Debug > 0 {
|
||||
l(fmt.Sprintf("<- %s", msg))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
24
game/game.go
24
game/game.go
|
@ -88,6 +88,8 @@ var (
|
|||
|
||||
statusLogged bool
|
||||
gameLogged bool
|
||||
|
||||
Debug int
|
||||
)
|
||||
|
||||
func l(s string) {
|
||||
|
@ -289,8 +291,6 @@ type Game struct {
|
|||
runeBuffer []rune
|
||||
userInput string
|
||||
|
||||
Debug int
|
||||
|
||||
debugImg *ebiten.Image
|
||||
|
||||
keyboard *kibodo.Keyboard
|
||||
|
@ -591,11 +591,11 @@ func (g *Game) Update() error { // Called by ebiten only when input occurs
|
|||
}
|
||||
|
||||
if ebiten.IsKeyPressed(ebiten.KeyControl) && inpututil.IsKeyJustPressed(ebiten.KeyD) {
|
||||
g.Debug++
|
||||
if g.Debug == 3 {
|
||||
g.Debug = 0
|
||||
Debug++
|
||||
if Debug == 3 {
|
||||
Debug = 0
|
||||
}
|
||||
g.Board.debug = g.Debug
|
||||
g.Board.debug = Debug
|
||||
}
|
||||
|
||||
if inpututil.IsKeyJustPressed(ebiten.KeyEscape) {
|
||||
|
@ -631,16 +631,16 @@ func (g *Game) Draw(screen *ebiten.Image) {
|
|||
if !g.loggedIn {
|
||||
g.keyboard.Draw(screen)
|
||||
|
||||
const welcomeText = `Please enter your FIBS username and password.
|
||||
If you do not have a FIBS account yet, visit
|
||||
http://www.com/help.html#register`
|
||||
const welcomeText = `Connect to bgammon.org
|
||||
To log in as a guest, enter a username (if you want) and
|
||||
do not enter a password.`
|
||||
debugBox := image.NewRGBA(image.Rect(0, 0, g.screenW, g.screenH))
|
||||
debugImg := ebiten.NewImageFromImage(debugBox)
|
||||
|
||||
if !g.usernameConfirmed {
|
||||
ebitenutil.DebugPrint(debugImg, welcomeText+fmt.Sprintf("\n\nUsername: %s", g.Username))
|
||||
ebitenutil.DebugPrint(debugImg, welcomeText+fmt.Sprintf("\n\nUsername: %s_", g.Username))
|
||||
} else {
|
||||
ebitenutil.DebugPrint(debugImg, welcomeText+fmt.Sprintf("\n\nPassword: %s", strings.Repeat("*", len(g.Password))))
|
||||
ebitenutil.DebugPrint(debugImg, welcomeText+fmt.Sprintf("\n\nPassword: %s_", strings.Repeat("*", len(g.Password))))
|
||||
}
|
||||
|
||||
g.resetImageOptions()
|
||||
|
@ -660,7 +660,7 @@ http://www.com/help.html#register`
|
|||
g.Board.draw(screen)
|
||||
}
|
||||
|
||||
if g.Debug > 0 {
|
||||
if Debug > 0 {
|
||||
g.drawBuffer.Reset()
|
||||
|
||||
g.drawBuffer.Write([]byte(fmt.Sprintf("FPS %c %0.0f", spinner[g.spinnerIndex], ebiten.CurrentFPS())))
|
||||
|
|
|
@ -227,26 +227,31 @@ func (l *lobby) drawBuffer() {
|
|||
cx, cy := 0.0, 0.0 // Cursor
|
||||
drawEntry(cx+l.padding, cy+l.padding-titleOffset, "Status", "Name", false, true)
|
||||
cy += l.entryH
|
||||
i := 0
|
||||
var status string
|
||||
for _, entry := range l.games {
|
||||
if i >= l.offset {
|
||||
if entry.Players == 2 {
|
||||
status = "Full"
|
||||
} else {
|
||||
if !entry.Password {
|
||||
status = "Open"
|
||||
|
||||
if len(l.games) == 0 {
|
||||
drawEntry(cx+l.padding, cy+l.padding, "No matches available. Please create one.", "", false, false)
|
||||
} else {
|
||||
i := 0
|
||||
var status string
|
||||
for _, entry := range l.games {
|
||||
if i >= l.offset {
|
||||
if entry.Players == 2 {
|
||||
status = "Full"
|
||||
} else {
|
||||
status = "Private"
|
||||
if !entry.Password {
|
||||
status = "Open"
|
||||
} else {
|
||||
status = "Private"
|
||||
}
|
||||
}
|
||||
|
||||
drawEntry(cx+l.padding, cy+l.padding, status, entry.Name, i == l.selected, false)
|
||||
|
||||
cy += l.entryH
|
||||
}
|
||||
|
||||
drawEntry(cx+l.padding, cy+l.padding, status, entry.Name, i == l.selected, false)
|
||||
|
||||
cy += l.entryH
|
||||
i++
|
||||
}
|
||||
|
||||
i++
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue