Add website and version to title screen

This commit is contained in:
Trevor Slocum 2019-10-21 16:17:58 -07:00
parent 0967a54295
commit 8196f84ad9
9 changed files with 52 additions and 38 deletions

View file

@ -44,6 +44,16 @@ See [GAMEPLAY.md](https://man.sr.ht/~tslocum/netris/GAMEPLAY.md)
Please share suggestions/issues [here](https://todo.sr.ht/~tslocum/netris).
## Libraries
The following libraries are used to build netris:
* [tcell](https://github.com/gdamore/tcell) - User interface
* [tview](https://github.com/rivo/tview) - User interface
* [ssh](github.com/gliderlabs/ssh) - SSH server
* [pty](github.com/creack/pty) - Pseudo-terminal interface
* [go-isatty](github.com/mattn/go-isatty) - Terminal detection
## Disclaimer
Tetris is a registered trademark of the Tetris Holding, LLC.

View file

@ -219,11 +219,15 @@ func initGUI(skipTitle bool) (*tview.Application, error) {
buttonC = tview.NewButton("C")
buttonLabelC = tview.NewTextView().SetTextAlign(tview.AlignCenter)
titleNameGrid := tview.NewGrid().SetRows(5).
AddItem(titleName, 0, 0, 1, 1, 0, 0, false).
AddItem(tview.NewTextView().SetText(SubTitle+game.Version), 1, 0, 1, 1, 0, 0, false)
titleGrid = tview.NewGrid().
SetRows(7, 3, 3, 3, 3, 3, 2).
SetColumns(-1, 38, -1).
AddItem(titleL, 0, 0, 7, 1, 0, 0, false).
AddItem(titleName, 0, 1, 1, 1, 0, 0, false).
AddItem(titleNameGrid, 0, 1, 1, 1, 0, 0, false).
AddItem(titleR, 0, 2, 7, 1, 0, 0, false).
AddItem(buttonA, 1, 1, 1, 1, 0, 0, false).
AddItem(buttonLabelA, 2, 1, 1, 1, 0, 0, false).
@ -243,7 +247,7 @@ func initGUI(skipTitle bool) (*tview.Application, error) {
SetRows(7, 2, -1, 1).
SetColumns(-1, 38, -1).
AddItem(titleL, 0, 0, 3, 1, 0, 0, false).
AddItem(titleName, 0, 1, 1, 1, 0, 0, false).
AddItem(titleNameGrid, 0, 1, 1, 1, 0, 0, false).
AddItem(titleR, 0, 2, 3, 1, 0, 0, false).
AddItem(playerSettingsTitle, 1, 1, 1, 1, 0, 0, true).
AddItem(playerSettingsForm, 2, 1, 1, 1, 0, 0, true).
@ -302,7 +306,7 @@ func initGUI(skipTitle bool) (*tview.Application, error) {
SetRows(7, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1).
SetColumns(-1, 38, -1).
AddItem(titleL, 0, 0, 16, 1, 0, 0, false).
AddItem(titleName, 0, 1, 1, 1, 0, 0, false).
AddItem(titleNameGrid, 0, 1, 1, 1, 0, 0, false).
AddItem(titleR, 0, 2, 16, 1, 0, 0, false).
AddItem(gameSettingsTitle, 1, 1, 1, 1, 0, 0, false).
AddItem(rotateCCWGrid, 2, 1, 1, 1, 0, 0, false).

View file

@ -11,6 +11,10 @@ import (
"github.com/tslocum/tview"
)
const (
SubTitle = " .rocketnine.space v"
)
var (
titleVisible bool
titleScreen int
@ -290,7 +294,6 @@ func newTitleMatrixName() *mino.Matrix {
m := mino.NewMatrix(36, 7, 0, 1, ev, draw, mino.MatrixCustom)
baseStart := 1
centerStart := (m.W / 2) - 17
var titleBlocks = []struct {
@ -371,7 +374,7 @@ func newTitleMatrixName() *mino.Matrix {
}
for _, titleBlock := range titleBlocks {
if !m.SetBlock(centerStart+titleBlock.X, baseStart+titleBlock.Y, titleBlock.Block, false) {
if !m.SetBlock(centerStart+titleBlock.X, titleBlock.Y, titleBlock.Block, false) {
log.Fatalf("failed to set title block %s", titleBlock.Point)
}
}

View file

@ -50,12 +50,6 @@ func init() {
log.SetFlags(0)
}
func fibonacci(value int) int {
if value == 0 || value == 1 {
return value
}
return fibonacci(value-2) + fibonacci(value-1)
}
func main() {
defer func() {
if r := recover(); r != nil {

2
go.mod
View file

@ -11,5 +11,5 @@ require (
github.com/mattn/go-isatty v0.0.10
github.com/tslocum/tview v0.0.0-20191018041445-09b275a4b660
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550
golang.org/x/sys v0.0.0-20191018095205-727590c5006e // indirect
golang.org/x/sys v0.0.0-20191020212454-3e7259c5e7c2 // indirect
)

4
go.sum
View file

@ -33,8 +33,8 @@ golang.org/x/sys v0.0.0-20190626150813-e07cf5db2756/go.mod h1:h1NjWce9XRLGQEsW7w
golang.org/x/sys v0.0.0-20191008105621-543471e840be/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20191010194322-b09406accb47 h1:/XfQ9z7ib8eEJX2hdgFTZJ/ntt0swNk5oYBziWeTCvY=
golang.org/x/sys v0.0.0-20191010194322-b09406accb47/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20191018095205-727590c5006e h1:ZtoklVMHQy6BFRHkbG6JzK+S6rX82//Yeok1vMlizfQ=
golang.org/x/sys v0.0.0-20191018095205-727590c5006e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20191020212454-3e7259c5e7c2 h1:nq114VpM8lsSlP+lyUbANecYHYiFcSNFtqcBlxRV+gA=
golang.org/x/sys v0.0.0-20191020212454-3e7259c5e7c2/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.2 h1:tW2bmiBqwgJj/UpqtC8EpXEZVYOwU0yG4iWbprSVAcs=

View file

@ -31,17 +31,19 @@ builds:
goarch:
- 386
- amd64
archive:
replacements:
386: i386
format_overrides:
- goos: windows
format: zip
files:
- CHANGELOG.md
- CONFIGURATION.md
- GAMEPLAY.md
- LICENSE
- README.md
archives:
-
id: netris
builds:
- netris
- netris-server
replacements:
386: i386
format_overrides:
- goos: windows
format: zip
files:
- ./*.md
- LICENSE
checksum:
name_template: 'checksums.txt'

View file

@ -24,7 +24,7 @@ const (
LogVerbose
)
var Version string
var Version = "0.0.0"
type Game struct {
ID int

View file

@ -13,8 +13,8 @@ import (
)
const (
GarbageDelay = 1500 * time.Millisecond
ComboBaseTime = 2.4 // Seconds
GarbageDelay = 1500 * time.Millisecond // 1.5 seconds
ComboBaseTime = 2.4 // Seconds
)
type MatrixType int
@ -61,9 +61,6 @@ type Matrix struct {
sync.Mutex `json:"-"`
}
// Type alias used during marshalling
type LockedMatrix *Matrix
func I(x int, y int, w int) int {
return (y * w) + x
}
@ -89,12 +86,6 @@ func (m *Matrix) Unlock() {
}
*/
func (m *Matrix) MarshalJSON() ([]byte, error) {
m.Lock()
defer m.Unlock()
return json.Marshal(*LockedMatrix(m))
}
func (m *Matrix) HandleReceiveGarbage() {
t := time.NewTicker(500 * time.Millisecond)
for {
@ -961,3 +952,13 @@ func (m *Matrix) AddTestBlocks() {
}
}
}
// Type alias used during marshalling
type LockedMatrix *Matrix
func (m *Matrix) MarshalJSON() ([]byte, error) {
m.Lock()
defer m.Unlock()
return json.Marshal(*LockedMatrix(m))
}