~whereswaldon/pointstar

b9abb3d7b27db047183953f5e960fddbaa2f35e7 — Chris Waldon 1 year, 7 months ago 8f5d2ad
deps: update to latest gio
5 files changed, 39 insertions(+), 36 deletions(-)

M client/main.go
M client/skin.go
M client/widgets/gameui/card.go
M go.mod
M go.sum
M client/main.go => client/main.go +2 -2
@@ 89,7 89,7 @@ func eventLoop(w *app.Window) error {
	gofont.Register()
	th := gameui.NewGameTheme()
	skin := &Skin{th}
	gtx := layout.NewContext(w.Queue())
	gtx := new(layout.Context)
	for {
		switch e := (<-w.Events()).(type) {
		case system.DestroyEvent:


@@ 116,7 116,7 @@ func eventLoop(w *app.Window) error {
				}
			default:
			}
			gtx.Reset(e.Config, e.Size)
			gtx.Reset(e.Queue, e.Config, e.Size)
			skin.LayoutAll(game, &ui, gtx)
			e.Frame(gtx.Ops)
		}

M client/skin.go => client/skin.go +29 -29
@@ 36,12 36,12 @@ func (s *Skin) LayoutAll(g *gamestate.GameState, u *UIState, gtx *layout.Context
	case !u.Connected && !u.HasConnected:
		log.Println("connecting")
		layout.Center.Layout(gtx, func() {
			s.H3("Connecting to server...").Layout(gtx)
			material.H3(s.Theme.Theme, "Connecting to server...").Layout(gtx)
		})
	case !u.Connected && u.HasConnected:
		log.Println("Disconnected")
		layout.Center.Layout(gtx, func() {
			s.H3("Disconnected unexpectedly! Try reloading to play again.").Layout(gtx)
			material.H3(s.Theme.Theme, "Disconnected unexpectedly! Try reloading to play again.").Layout(gtx)
		})
	default:
		switch g.Phase {


@@ 72,7 72,7 @@ func (s *Skin) LayoutVerboseHeader(gtx *layout.Context) {
		layout.Rigid(func() {
			gtx.Constraints.Width.Min = gtx.Constraints.Width.Max
			layout.Center.Layout(gtx, func() {
				heading := s.H1(".*")
				heading := material.H1(s.Theme.Theme, ".*")
				heading.Alignment = text.Middle
				heading.Layout(gtx)
			})


@@ 80,7 80,7 @@ func (s *Skin) LayoutVerboseHeader(gtx *layout.Context) {
		layout.Rigid(func() {
			gtx.Constraints.Width.Min = gtx.Constraints.Width.Max
			layout.Center.Layout(gtx, func() {
				body := s.Body1("Welcome to pointstar, a sci-fi strategy card game!")
				body := material.Body1(s.Theme.Theme, "Welcome to pointstar, a sci-fi strategy card game!")
				body.Alignment = text.Middle
				body.Layout(gtx)
			})


@@ 107,12 107,12 @@ func (s *Skin) LayoutLobby(g *gamestate.GameState, u *UIState, gtx *layout.Conte
							layout.Flexed(.5, func() {}),
							layout.Rigid(func() {
								layout.UniformInset(unit.Dp(8)).Layout(gtx, func() {
									s.Theme.Editor("Username").Layout(gtx, &u.NameEditor)
									material.Editor(s.Theme.Theme, "Username").Layout(gtx, &u.NameEditor)
								})
							}),
							layout.Rigid(func() {
								layout.UniformInset(unit.Dp(8)).Layout(gtx, func() {
									s.Theme.Button("Submit").Layout(gtx, &u.NameSubmit)
									material.Button(s.Theme.Theme, "Submit").Layout(gtx, &u.NameSubmit)
								})
							}),
							layout.Flexed(.5, func() {}))


@@ 137,7 137,7 @@ func (s *Skin) LayoutLobby(g *gamestate.GameState, u *UIState, gtx *layout.Conte
								layout.Center.Layout(gtx, func() {
									layout.UniformInset(unit.Dp(8)).Layout(gtx, func() {
										msg := "waiting for other players..."
										s.Theme.H3(msg).Layout(gtx)
										material.H3(s.Theme.Theme, msg).Layout(gtx)
									})
								})
							}),


@@ 149,7 149,7 @@ func (s *Skin) LayoutLobby(g *gamestate.GameState, u *UIState, gtx *layout.Conte
								}
								layout.Center.Layout(gtx, func() {
									layout.UniformInset(unit.Dp(8)).Layout(gtx, func() {
										s.Theme.H4(players).Layout(gtx)
										material.H4(s.Theme.Theme, players).Layout(gtx)
									})
								})
							}),


@@ 160,16 160,16 @@ func (s *Skin) LayoutLobby(g *gamestate.GameState, u *UIState, gtx *layout.Conte
										layout.Rigid(func() {
											layout.UniformInset(unit.Dp(8)).Layout(gtx, func() {
												if u.PlayerNum == 0 {
													s.Theme.Button("Start game").Layout(gtx, &u.StartButton)
													material.Button(s.Theme.Theme, "Start game").Layout(gtx, &u.StartButton)
												} else {
													s.Theme.H6("The first player to join can start the game at any time.").Layout(gtx)
													material.H6(s.Theme.Theme, "The first player to join can start the game at any time.").Layout(gtx)
												}
											})
										}),
										layout.Rigid(func() {
											layout.UniformInset(unit.Dp(8)).Layout(gtx, func() {
												if u.PlayerNum == 0 {
													s.Theme.Button("Add AI Player").Layout(gtx, &u.AddAIPlayerButton)
													material.Button(s.Theme.Theme, "Add AI Player").Layout(gtx, &u.AddAIPlayerButton)
												}
											})
										}),


@@ 195,14 195,14 @@ func (s *Skin) LayoutHelp(g *gamestate.GameState, u *UIState, gtx *layout.Contex
				gtx.Constraints.Width.Min = gtx.Constraints.Width.Max
				layout.Center.Layout(gtx, func() {
					layout.UniformInset(unit.Dp(8)).Layout(gtx, func() {
						s.Theme.Button("Close Help").Layout(gtx, &u.HelpButton)
						material.Button(s.Theme.Theme, "Close Help").Layout(gtx, &u.HelpButton)
					})
				})
			}),
			layout.Rigid(func() {
				gtx.Constraints.Width.Max = helpWidth
				gtx.Constraints.Width.Min = gtx.Constraints.Width.Max
				s.Theme.Body1(gamestate.RulesText).Layout(gtx)
				material.Body1(s.Theme.Theme, gamestate.RulesText).Layout(gtx)
			}),
			layout.Flexed(1, func() {
				widgets := []func(){}


@@ 226,10 226,10 @@ func (s *Skin) LayoutHelp(g *gamestate.GameState, u *UIState, gtx *layout.Contex
								layout.W.Layout(gtx, func() {
									layout.Flex{Axis: layout.Vertical}.Layout(gtx,
										layout.Rigid(func() {
											s.Theme.Body2(gamestate.CardTypes[card].String()).Layout(gtx)
											material.Body2(s.Theme.Theme, gamestate.CardTypes[card].String()).Layout(gtx)
										}),
										layout.Rigid(func() {
											s.Theme.Body1(gamestate.CardHelpText[card]).Layout(gtx)
											material.Body1(s.Theme.Theme, gamestate.CardHelpText[card]).Layout(gtx)
										}),
									)
								})


@@ 306,7 306,7 @@ func (s *Skin) LayoutTable(g *gamestate.GameState, u *UIState, gtx *layout.Conte
							Top:  unit.Dp(8),
							Left: unit.Dp(8),
						}.Layout(gtx, func() {
							name := s.Body1(gamestate.CardNames[hoveredCard] + " (" + gamestate.CardTypes[hoveredCard].String() + "):")
							name := material.Body1(s.Theme.Theme, gamestate.CardNames[hoveredCard]+" ("+gamestate.CardTypes[hoveredCard].String()+"):")

							name.Font.Weight = text.Bold
							name.Layout(gtx)


@@ 314,7 314,7 @@ func (s *Skin) LayoutTable(g *gamestate.GameState, u *UIState, gtx *layout.Conte
					}),
					layout.Rigid(func() {
						layout.UniformInset(unit.Dp(8)).Layout(gtx, func() {
							s.Body2(gamestate.CardHelpText[hoveredCard]).Layout(gtx)
							material.Body2(s.Theme.Theme, gamestate.CardHelpText[hoveredCard]).Layout(gtx)
						})
					}),
				)


@@ 352,7 352,7 @@ func (s *Skin) LayoutPlayed(g *gamestate.GameState, playerNum int, u *UIState, g
				gtx.Constraints.Width.Min = gtx.Constraints.Width.Max
				layout.Flex{Axis: layout.Vertical}.Layout(gtx,
					layout.Rigid(func() {
						playerName := s.Theme.H3(player.Name)
						playerName := material.H3(s.Theme.Theme, player.Name)
						if wonCurrentBattle {
							playerName.Color = VictoryTextColor
						} else if g.Turn == playerNum && g.Phase != gamestate.FinishingBattle {


@@ 365,10 365,10 @@ func (s *Skin) LayoutPlayed(g *gamestate.GameState, playerNum int, u *UIState, g
						playerName.Layout(gtx)
					}),
					layout.Rigid(func() {
						s.Theme.H6(fmt.Sprintf("Victories: %d", player.Victories)).Layout(gtx)
						material.H6(s.Theme.Theme, fmt.Sprintf("Victories: %d", player.Victories)).Layout(gtx)
					}),
					layout.Rigid(func() {
						s.Theme.H6(fmt.Sprintf("Hand: %d", len(player.Hand))).Layout(gtx)
						material.H6(s.Theme.Theme, fmt.Sprintf("Hand: %d", len(player.Hand))).Layout(gtx)
					}),
				)
			})


@@ 387,20 387,20 @@ func (s *Skin) LayoutPlayed(g *gamestate.GameState, playerNum int, u *UIState, g
			layout.Inset{Right: unit.Dp(8), Top: unit.Dp(8)}.Layout(gtx, func() {
				layout.Flex{Axis: layout.Vertical}.Layout(gtx,
					layout.Rigid(func() {
						var heading material.Label
						var heading material.LabelStyle
						if player.IsPassing {
							heading = s.H6("Passed:")
							heading = material.H6(s.Theme.Theme, "Passed:")
							heading.Color.A = 155
						} else if wonCurrentBattle {
							heading = s.H6("Victory:")
							heading = material.H6(s.Theme.Theme, "Victory:")
							heading.Color = VictoryTextColor
						} else {
							heading = s.H6("Strength:")
							heading = material.H6(s.Theme.Theme, "Strength:")
						}
						heading.Layout(gtx)
					}),
					layout.Rigid(func() {
						strength := s.H2(strconv.Itoa(hand.Score(g)))
						strength := material.H2(s.Theme.Theme, strconv.Itoa(hand.Score(g)))
						if wonCurrentBattle {
							strength.Color = VictoryTextColor
						}


@@ 425,7 425,7 @@ func (s *Skin) LayoutHand(g *gamestate.GameState, u *UIState, gtx *layout.Contex
		layout.Rigid(func() {
			layout.SW.Layout(gtx, func() {
				layout.Inset{Left: unit.Dp(8)}.Layout(gtx, func() {
					s.H6("Your hand:").Layout(gtx)
					material.H6(s.Theme.Theme, "Your hand:").Layout(gtx)
				})
			})
		}),


@@ 450,7 450,7 @@ func (s *Skin) LayoutHand(g *gamestate.GameState, u *UIState, gtx *layout.Contex
										gtx.Constraints.Width.Min = cardWidth
										layout.Center.Layout(gtx, func() {
											if isPlayersTurn {
												s.Theme.Button("Play").Layout(gtx, button)
												material.Button(s.Theme.Theme, "Play").Layout(gtx, button)
											}
										})
									}),


@@ 465,13 465,13 @@ func (s *Skin) LayoutHand(g *gamestate.GameState, u *UIState, gtx *layout.Contex
							layout.Rigid(func() {
								if isPlayersTurn {
									layout.UniformInset(unit.Dp(8)).Layout(gtx, func() {
										s.Theme.Button("Pass").Layout(gtx, &u.PassButton)
										material.Button(s.Theme.Theme, "Pass").Layout(gtx, &u.PassButton)
									})
								}
							}),
							layout.Rigid(func() {
								layout.UniformInset(unit.Dp(8)).Layout(gtx, func() {
									s.Theme.Button("Help").Layout(gtx, &u.HelpButton)
									material.Button(s.Theme.Theme, "Help").Layout(gtx, &u.HelpButton)
								})
							}),
						)

M client/widgets/gameui/card.go => client/widgets/gameui/card.go +1 -1
@@ 84,7 84,7 @@ func (g *Theme) LayoutCard(c gamestate.Card, cardState *widgets.Card, gtx *layou
			gtx.Constraints.Width.Min = cardWidth
			gtx.Constraints.Height.Min = cardHeight
			layout.Center.Layout(gtx, func() {
				h := g.Theme.H2(gamestate.CardText[c])
				h := material.H2(g.Theme, gamestate.CardText[c])
				h.Color = textColor
				h.Layout(gtx)
			})

M go.mod => go.mod +2 -4
@@ 3,9 3,7 @@ module git.sr.ht/~whereswaldon/pointstar
go 1.14

require (
	gioui.org v0.0.0-20200423191319-533bf953f987
	gioui.org/cmd v0.0.0-20200424135930-84d4800a1612 // indirect
	gioui.org v0.0.0-20200504124128-13941c9f1b3c
	gioui.org/cmd v0.0.0-20200504124128-13941c9f1b3c // indirect
	nhooyr.io/websocket v1.8.4
)

replace gioui.org => git.sr.ht/~whereswaldon/gio v0.0.0-20200425212652-6e3f5f1d8965

M go.sum => go.sum +5 -0
@@ 1,6 1,11 @@
dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU=
gioui.org v0.0.0-20200503190452-8d9612f9aa46/go.mod h1:AHI9rFr6AEEHCb8EPVtb/p5M+NMJRKH58IOp8O3Je04=
gioui.org v0.0.0-20200504124128-13941c9f1b3c h1:Ec+6k+PGvmEEc5q7822+IbfetMmqKCp2FaP8O/hkJNc=
gioui.org v0.0.0-20200504124128-13941c9f1b3c/go.mod h1:AHI9rFr6AEEHCb8EPVtb/p5M+NMJRKH58IOp8O3Je04=
gioui.org/cmd v0.0.0-20200424135930-84d4800a1612 h1:utHFWXNYQuJ6pjLpuUEf/pJKWB8Q/Rx3QJbVCaanqRw=
gioui.org/cmd v0.0.0-20200424135930-84d4800a1612/go.mod h1:KD+OtAQHeyTNNkaXyXyLZz2q8uFiS/e3h3gOp+XzO4Q=
gioui.org/cmd v0.0.0-20200504124128-13941c9f1b3c h1:r7ffEP3U9hLJUG02r/Q0G0DBrrJmkHp5fta9TNaAQVE=
gioui.org/cmd v0.0.0-20200504124128-13941c9f1b3c/go.mod h1:pSCbdDbqNf8zuUHR3zv2om4R2946FUJBOI618vt5AoE=
git.sr.ht/~whereswaldon/gio v0.0.0-20200425212652-6e3f5f1d8965 h1:jwITP5+4kfnIszGgSwzX/pGREENTDkUXNhLaL0dnC5w=
git.sr.ht/~whereswaldon/gio v0.0.0-20200425212652-6e3f5f1d8965/go.mod h1:AHI9rFr6AEEHCb8EPVtb/p5M+NMJRKH58IOp8O3Je04=
github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=