Use default terminal colors
This commit is contained in:
parent
2e08a42ac9
commit
e8207a9f1d
9 changed files with 176 additions and 75 deletions
|
@ -1,8 +1,21 @@
|
|||
image: golang:latest
|
||||
|
||||
stages:
|
||||
- test
|
||||
- validate
|
||||
- build
|
||||
|
||||
fmt:
|
||||
stage: validate
|
||||
script:
|
||||
- gofmt -l -s -e .
|
||||
- exit $(gofmt -l -s -e . | wc -l)
|
||||
|
||||
vet:
|
||||
stage: validate
|
||||
script:
|
||||
- go vet -composites=false ./...
|
||||
|
||||
test:
|
||||
image: golang:latest
|
||||
stage: test
|
||||
stage: validate
|
||||
script:
|
||||
- go test -v ./...
|
||||
- go test -race -v ./...
|
||||
|
|
|
@ -1,3 +1,6 @@
|
|||
0.1.5:
|
||||
- Use default terminal colors
|
||||
|
||||
0.1.4:
|
||||
- Allow ghost piece to be disabled
|
||||
- Add mouse support
|
||||
|
|
|
@ -27,9 +27,7 @@ Windows and Linux binaries are available.
|
|||
|
||||
### Compile
|
||||
|
||||
```
|
||||
GO111MODULE=on go get gitlab.com/tslocum/netris/...
|
||||
```
|
||||
```go get gitlab.com/tslocum/netris/cmd/netris```
|
||||
|
||||
## Configure
|
||||
|
||||
|
@ -41,7 +39,7 @@ See [GAMEPLAY.md](https://gitlab.com/tslocum/netris/blob/master/GAMEPLAY.md)
|
|||
|
||||
## Support
|
||||
|
||||
Please share issues/suggestions [here](https://gitlab.com/tslocum/netris/issues).
|
||||
Please share issues and suggestions [here](https://gitlab.com/tslocum/netris/issues).
|
||||
|
||||
## Libraries
|
||||
|
||||
|
|
|
@ -463,13 +463,32 @@ func renderMatrixes(mx []*mino.Matrix) {
|
|||
}
|
||||
|
||||
for x := 0; x < m.W; x++ {
|
||||
if m.Block(x, y-1) == mino.BlockNone && m.Block(x, y) == mino.BlockNone {
|
||||
renderBuffer.WriteRune(' ')
|
||||
continue
|
||||
} else if m.Block(x, y-1) == mino.BlockNone {
|
||||
renderBuffer.WriteRune('[')
|
||||
renderBuffer.Write(mino.Colors[m.Block(x, y)])
|
||||
renderBuffer.WriteRune(']')
|
||||
renderBuffer.WriteRune('▀')
|
||||
renderBuffer.Write([]byte("[-:-]"))
|
||||
continue
|
||||
} else if m.Block(x, y) == mino.BlockNone {
|
||||
renderBuffer.WriteRune('[')
|
||||
renderBuffer.Write(mino.Colors[m.Block(x, y-1)])
|
||||
renderBuffer.WriteRune(']')
|
||||
renderBuffer.WriteRune('▄')
|
||||
renderBuffer.Write([]byte("[-:-]"))
|
||||
continue
|
||||
}
|
||||
|
||||
renderBuffer.WriteRune('[')
|
||||
renderBuffer.Write(mino.Colors[m.Block(x, y-1)])
|
||||
renderBuffer.WriteRune(':')
|
||||
renderBuffer.Write(mino.Colors[m.Block(x, y)])
|
||||
renderBuffer.WriteRune(']')
|
||||
renderBuffer.WriteRune('▄')
|
||||
renderBuffer.Write([]byte("[#FFFFFF:#000000]"))
|
||||
renderBuffer.Write([]byte("[-:-]"))
|
||||
}
|
||||
|
||||
if m.Type == mino.MatrixStandard {
|
||||
|
@ -497,12 +516,18 @@ func renderMatrixes(mx []*mino.Matrix) {
|
|||
}
|
||||
|
||||
for x := 0; x < m.W; x++ {
|
||||
if m.Block(x, y) == mino.BlockNone {
|
||||
renderBuffer.WriteRune(' ')
|
||||
renderBuffer.WriteRune(' ')
|
||||
continue
|
||||
}
|
||||
|
||||
renderBuffer.WriteRune('[')
|
||||
renderBuffer.Write(mino.Colors[m.Block(x, y)])
|
||||
renderBuffer.WriteRune(']')
|
||||
renderBuffer.WriteRune('█')
|
||||
renderBuffer.WriteRune('█')
|
||||
renderBuffer.Write([]byte("[#FFFFFF]"))
|
||||
renderBuffer.Write([]byte("[-]"))
|
||||
}
|
||||
|
||||
if m.Type == mino.MatrixStandard {
|
||||
|
@ -531,6 +556,14 @@ func renderMatrixes(mx []*mino.Matrix) {
|
|||
}
|
||||
|
||||
for x := 0; x < m.W; x++ {
|
||||
if m.Block(x, y) == mino.BlockNone {
|
||||
renderBuffer.WriteRune(' ')
|
||||
renderBuffer.WriteRune(' ')
|
||||
renderBuffer.WriteRune(' ')
|
||||
renderBuffer.WriteRune(' ')
|
||||
continue
|
||||
}
|
||||
|
||||
renderBuffer.WriteRune('[')
|
||||
renderBuffer.Write(mino.Colors[m.Block(x, y)])
|
||||
renderBuffer.WriteRune(']')
|
||||
|
@ -538,7 +571,7 @@ func renderMatrixes(mx []*mino.Matrix) {
|
|||
renderBuffer.WriteRune('█')
|
||||
renderBuffer.WriteRune('█')
|
||||
renderBuffer.WriteRune('█')
|
||||
renderBuffer.Write([]byte("[#FFFFFF]"))
|
||||
renderBuffer.Write([]byte("[-]"))
|
||||
}
|
||||
|
||||
if m.Type == mino.MatrixStandard {
|
||||
|
|
|
@ -20,8 +20,10 @@ func initGUI(skipTitle bool) (*cview.Application, error) {
|
|||
SetText(DefaultStatusText).
|
||||
SetLabel("> ").
|
||||
SetFieldWidth(0).
|
||||
SetFieldBackgroundColor(tcell.ColorBlack).
|
||||
SetFieldTextColor(tcell.ColorWhite)
|
||||
SetFieldBackgroundColor(tcell.ColorDefault).
|
||||
SetFieldTextColor(tcell.ColorDefault)
|
||||
|
||||
inputView.SetBackgroundColor(tcell.ColorDefault)
|
||||
|
||||
inputView.SetInputCapture(func(event *tcell.EventKey) *tcell.EventKey {
|
||||
if !inputActive {
|
||||
|
@ -40,7 +42,7 @@ func initGUI(skipTitle bool) (*cview.Application, error) {
|
|||
SetWrap(false).
|
||||
SetWordWrap(false)
|
||||
|
||||
mtx.SetDynamicColors(true)
|
||||
mtx.SetDynamicColors(true).SetTextColor(tcell.ColorDefault).SetBackgroundColor(tcell.ColorDefault)
|
||||
|
||||
side = cview.NewTextView().
|
||||
SetScrollable(false).
|
||||
|
@ -48,7 +50,7 @@ func initGUI(skipTitle bool) (*cview.Application, error) {
|
|||
SetWrap(false).
|
||||
SetWordWrap(false)
|
||||
|
||||
side.SetDynamicColors(true)
|
||||
side.SetDynamicColors(true).SetTextColor(tcell.ColorDefault).SetBackgroundColor(tcell.ColorDefault)
|
||||
|
||||
buffer = cview.NewTextView().
|
||||
SetScrollable(false).
|
||||
|
@ -56,9 +58,9 @@ func initGUI(skipTitle bool) (*cview.Application, error) {
|
|||
SetWrap(false).
|
||||
SetWordWrap(false)
|
||||
|
||||
buffer.SetDynamicColors(true)
|
||||
buffer.SetDynamicColors(true).SetTextColor(tcell.ColorDefault).SetBackgroundColor(tcell.ColorDefault)
|
||||
|
||||
pad := cview.NewBox()
|
||||
pad := cview.NewBox().SetBackgroundColor(tcell.ColorDefault)
|
||||
|
||||
recent = cview.NewTextView().
|
||||
SetScrollable(true).
|
||||
|
@ -66,6 +68,8 @@ func initGUI(skipTitle bool) (*cview.Application, error) {
|
|||
SetWrap(true).
|
||||
SetWordWrap(true)
|
||||
|
||||
recent.SetTextColor(tcell.ColorDefault).SetBackgroundColor(tcell.ColorDefault)
|
||||
|
||||
gameGrid.
|
||||
AddItem(pad, 0, 0, 4, 1, 0, 0, false).
|
||||
AddItem(pad, 0, 1, 1, 2, 0, 0, false).
|
||||
|
@ -120,18 +124,21 @@ func initGUI(skipTitle bool) (*cview.Application, error) {
|
|||
SetTextAlign(cview.AlignLeft).
|
||||
SetWrap(false).
|
||||
SetWordWrap(false).SetDynamicColors(true)
|
||||
titleName.SetTextColor(tcell.ColorDefault).SetBackgroundColor(tcell.ColorDefault)
|
||||
|
||||
titleL = cview.NewTextView().
|
||||
SetScrollable(false).
|
||||
SetTextAlign(cview.AlignLeft).
|
||||
SetWrap(false).
|
||||
SetWordWrap(false).SetDynamicColors(true)
|
||||
titleL.SetTextColor(tcell.ColorDefault).SetBackgroundColor(tcell.ColorDefault)
|
||||
|
||||
titleR = cview.NewTextView().
|
||||
SetScrollable(false).
|
||||
SetTextAlign(cview.AlignLeft).
|
||||
SetWrap(false).
|
||||
SetWordWrap(false).SetDynamicColors(true)
|
||||
titleR.SetTextColor(tcell.ColorDefault).SetBackgroundColor(tcell.ColorDefault)
|
||||
|
||||
go handleTitle()
|
||||
|
||||
|
@ -143,6 +150,7 @@ func initGUI(skipTitle bool) (*cview.Application, error) {
|
|||
selectTitleButton()
|
||||
})
|
||||
buttonLabelA = cview.NewTextView().SetTextAlign(cview.AlignCenter)
|
||||
buttonLabelA.SetTextColor(tcell.ColorDefault).SetBackgroundColor(tcell.ColorDefault)
|
||||
|
||||
buttonB = cview.NewButton("B").SetSelectedFunc(func() {
|
||||
titleSelectedButton = 1
|
||||
|
@ -152,6 +160,7 @@ func initGUI(skipTitle bool) (*cview.Application, error) {
|
|||
selectTitleButton()
|
||||
})
|
||||
buttonLabelB = cview.NewTextView().SetTextAlign(cview.AlignCenter)
|
||||
buttonLabelB.SetTextColor(tcell.ColorDefault).SetBackgroundColor(tcell.ColorDefault)
|
||||
|
||||
buttonC = cview.NewButton("C").SetSelectedFunc(func() {
|
||||
titleSelectedButton = 2
|
||||
|
@ -161,10 +170,14 @@ func initGUI(skipTitle bool) (*cview.Application, error) {
|
|||
selectTitleButton()
|
||||
})
|
||||
buttonLabelC = cview.NewTextView().SetTextAlign(cview.AlignCenter)
|
||||
buttonLabelC.SetTextColor(tcell.ColorDefault).SetBackgroundColor(tcell.ColorDefault)
|
||||
|
||||
subTitle := cview.NewTextView().SetText(SubTitle + game.Version)
|
||||
subTitle.SetTextColor(tcell.ColorDefault).SetBackgroundColor(tcell.ColorDefault)
|
||||
|
||||
titleNameGrid := cview.NewGrid().SetRows(3, 2).
|
||||
AddItem(titleName, 0, 0, 1, 1, 0, 0, false).
|
||||
AddItem(cview.NewTextView().SetText(SubTitle+game.Version), 1, 0, 1, 1, 0, 0, false)
|
||||
AddItem(subTitle, 1, 0, 1, 1, 0, 0, false)
|
||||
|
||||
titleGrid = cview.NewGrid().
|
||||
SetRows(5, 3, 3, 3, 3, 3, 3).
|
||||
|
@ -181,6 +194,7 @@ func initGUI(skipTitle bool) (*cview.Application, error) {
|
|||
AddItem(pad, 7, 1, 1, 1, 0, 0, false)
|
||||
|
||||
gameListView = cview.NewTextView().SetDynamicColors(true)
|
||||
gameListView.SetBackgroundColor(tcell.ColorDefault)
|
||||
|
||||
gameListButtonsGrid := cview.NewGrid().
|
||||
SetColumns(-1, 1, -1, 1, -1).
|
||||
|
@ -191,6 +205,13 @@ func initGUI(skipTitle bool) (*cview.Application, error) {
|
|||
AddItem(buttonC, 0, 4, 1, 1, 0, 0, false)
|
||||
|
||||
gameListHeader = cview.NewTextView().SetTextAlign(cview.AlignCenter)
|
||||
gameListHeader.SetBackgroundColor(tcell.ColorDefault)
|
||||
|
||||
gameListHelp := cview.NewTextView().
|
||||
SetTextAlign(cview.AlignCenter).
|
||||
SetWrap(false).
|
||||
SetWordWrap(false).SetText("\nRefresh: R\nPrevious: Shift+Tab - Next: Tab")
|
||||
gameListHelp.SetBackgroundColor(tcell.ColorDefault)
|
||||
|
||||
gameListGrid = cview.NewGrid().
|
||||
SetRows(5, 1, 14, 1, 3).
|
||||
|
@ -201,10 +222,7 @@ func initGUI(skipTitle bool) (*cview.Application, error) {
|
|||
AddItem(gameListHeader, 1, 1, 1, 1, 0, 0, true).
|
||||
AddItem(gameListView, 2, 1, 1, 1, 0, 0, true).
|
||||
AddItem(gameListButtonsGrid, 3, 1, 1, 1, 0, 0, true).
|
||||
AddItem(cview.NewTextView().
|
||||
SetTextAlign(cview.AlignCenter).
|
||||
SetWrap(false).
|
||||
SetWordWrap(false).SetText("\nRefresh: R\nPrevious: Shift+Tab - Next: Tab"), 4, 1, 1, 1, 0, 0, true)
|
||||
AddItem(gameListHelp, 4, 1, 1, 1, 0, 0, true)
|
||||
|
||||
buttonCancel = cview.NewButton("Cancel").SetSelectedFunc(selectTitleFunc(3))
|
||||
buttonStart = cview.NewButton("Start").SetSelectedFunc(selectTitleFunc(4))
|
||||
|
@ -221,28 +239,46 @@ func initGUI(skipTitle bool) (*cview.Application, error) {
|
|||
newGameMaxPlayersInput = cview.NewInputField().SetFieldWidth(3).SetAcceptanceFunc(func(textToCheck string, lastChar rune) bool {
|
||||
return unicode.IsDigit(lastChar) && len(textToCheck) <= 3
|
||||
})
|
||||
newGameMaxPlayersInput.SetBackgroundColor(tcell.ColorDefault)
|
||||
newGameSpeedLimitInput = cview.NewInputField().SetFieldWidth(3).SetAcceptanceFunc(func(textToCheck string, lastChar rune) bool {
|
||||
return unicode.IsDigit(lastChar) && len(textToCheck) <= 3
|
||||
})
|
||||
newGameSpeedLimitInput.SetBackgroundColor(tcell.ColorDefault)
|
||||
|
||||
resetNewGameInputs()
|
||||
|
||||
newGameNameLabel := cview.NewTextView().SetText("Name")
|
||||
newGameNameLabel.SetBackgroundColor(tcell.ColorDefault)
|
||||
|
||||
newGameNameGrid := cview.NewGrid().
|
||||
AddItem(cview.NewTextView().SetText("Name"), 0, 0, 1, 1, 0, 0, false).
|
||||
AddItem(newGameNameLabel, 0, 0, 1, 1, 0, 0, false).
|
||||
AddItem(newGameNameInput, 0, 1, 1, 1, 0, 0, false)
|
||||
|
||||
newGameMaxPlayersLabel := cview.NewTextView().SetText("Player Limit")
|
||||
newGameMaxPlayersLabel.SetBackgroundColor(tcell.ColorDefault)
|
||||
|
||||
newGameMaxPlayersGrid := cview.NewGrid().
|
||||
AddItem(cview.NewTextView().SetText("Player Limit"), 0, 0, 1, 1, 0, 0, false).
|
||||
AddItem(newGameMaxPlayersLabel, 0, 0, 1, 1, 0, 0, false).
|
||||
AddItem(newGameMaxPlayersInput, 0, 1, 1, 1, 0, 0, false)
|
||||
|
||||
newGameSpeedLimitLabel := cview.NewTextView().SetText("Speed Limit")
|
||||
newGameSpeedLimitLabel.SetBackgroundColor(tcell.ColorDefault)
|
||||
|
||||
newGameSpeedLimitGrid := cview.NewGrid().
|
||||
AddItem(cview.NewTextView().SetText("Speed Limit"), 0, 0, 1, 1, 0, 0, false).
|
||||
AddItem(newGameSpeedLimitLabel, 0, 0, 1, 1, 0, 0, false).
|
||||
AddItem(newGameSpeedLimitInput, 0, 1, 1, 1, 0, 0, false)
|
||||
|
||||
newGameHeader := cview.NewTextView().
|
||||
SetTextAlign(cview.AlignCenter).
|
||||
SetWrap(false).
|
||||
SetWordWrap(false).SetText("New Game")
|
||||
newGameHeader.SetBackgroundColor(tcell.ColorDefault)
|
||||
|
||||
newGameHelp := cview.NewTextView().
|
||||
SetTextAlign(cview.AlignCenter).
|
||||
SetWrap(false).
|
||||
SetWordWrap(false).SetText("\nLimits set to zero are disabled\nPrevious: Shift+Tab - Next: Tab")
|
||||
newGameHelp.SetBackgroundColor(tcell.ColorDefault)
|
||||
|
||||
newGameGrid = cview.NewGrid().
|
||||
SetRows(5, 2, 1, 1, 1, 1, 1, 1, 1, -1, 3).
|
||||
|
@ -259,17 +295,22 @@ func initGUI(skipTitle bool) (*cview.Application, error) {
|
|||
AddItem(pad, 7, 1, 1, 1, 0, 0, false).
|
||||
AddItem(newGameSubmitGrid, 8, 1, 1, 1, 0, 0, false).
|
||||
AddItem(pad, 9, 1, 1, 1, 0, 0, false).
|
||||
AddItem(cview.NewTextView().
|
||||
SetTextAlign(cview.AlignCenter).
|
||||
SetWrap(false).
|
||||
SetWordWrap(false).SetText("\nLimits set to zero are disabled\nPrevious: Shift+Tab - Next: Tab"), 10, 1, 1, 1, 0, 0, false)
|
||||
AddItem(newGameHelp, 10, 1, 1, 1, 0, 0, false)
|
||||
|
||||
playerSettingsTitle := cview.NewTextView().
|
||||
SetTextAlign(cview.AlignCenter).
|
||||
SetWrap(false).
|
||||
SetWordWrap(false).SetText("Player Settings")
|
||||
playerSettingsTitle.SetBackgroundColor(tcell.ColorDefault)
|
||||
|
||||
playerSettingsForm = cview.NewForm().SetButtonsAlign(cview.AlignCenter)
|
||||
playerSettingsForm.SetBackgroundColor(tcell.ColorDefault)
|
||||
|
||||
playerSettingsHelp := cview.NewTextView().
|
||||
SetTextAlign(cview.AlignCenter).
|
||||
SetWrap(false).
|
||||
SetWordWrap(false).SetText("Previous: Shift+Tab - Next: Tab")
|
||||
playerSettingsHelp.SetBackgroundColor(tcell.ColorDefault)
|
||||
|
||||
playerSettingsGrid = cview.NewGrid().
|
||||
SetRows(5, 2, -1, 1).
|
||||
|
@ -279,22 +320,36 @@ func initGUI(skipTitle bool) (*cview.Application, error) {
|
|||
AddItem(titleR, 0, 2, 4, 1, 0, 0, false).
|
||||
AddItem(playerSettingsTitle, 1, 1, 1, 1, 0, 0, true).
|
||||
AddItem(playerSettingsForm, 2, 1, 1, 1, 0, 0, true).
|
||||
AddItem(cview.NewTextView().
|
||||
SetTextAlign(cview.AlignCenter).
|
||||
SetWrap(false).
|
||||
SetWordWrap(false).SetText("Previous: Shift+Tab - Next: Tab"), 3, 1, 1, 1, 0, 0, true)
|
||||
AddItem(playerSettingsHelp, 3, 1, 1, 1, 0, 0, true)
|
||||
|
||||
gameSettingsTitle := cview.NewTextView().
|
||||
SetTextAlign(cview.AlignCenter).
|
||||
SetWrap(false).
|
||||
SetWordWrap(false).SetText("Game Settings")
|
||||
gameSettingsTitle.SetBackgroundColor(tcell.ColorDefault)
|
||||
|
||||
labelGhostPiece := cview.NewTextView().SetText("Ghost Piece")
|
||||
labelGhostPiece.SetBackgroundColor(tcell.ColorDefault)
|
||||
|
||||
buttonGhostPiece = cview.NewButton("Enabled").SetSelectedFunc(selectTitleFunc(0))
|
||||
|
||||
ghostPieceGrid := cview.NewGrid().SetColumns(19, -1).
|
||||
AddItem(cview.NewTextView().SetText("Ghost Piece"), 0, 0, 1, 1, 0, 0, false).
|
||||
AddItem(labelGhostPiece, 0, 0, 1, 1, 0, 0, false).
|
||||
AddItem(buttonGhostPiece, 0, 1, 1, 1, 0, 0, false)
|
||||
|
||||
labelKeybindRotateCCW := cview.NewTextView().SetText("Rotate CCW")
|
||||
labelKeybindRotateCCW.SetBackgroundColor(tcell.ColorDefault)
|
||||
labelKeybindRotateCW := cview.NewTextView().SetText("Rotate CW")
|
||||
labelKeybindRotateCW.SetBackgroundColor(tcell.ColorDefault)
|
||||
labelKeybindMoveLeft := cview.NewTextView().SetText("Move Left")
|
||||
labelKeybindMoveLeft.SetBackgroundColor(tcell.ColorDefault)
|
||||
labelKeybindMoveRight := cview.NewTextView().SetText("Move Right")
|
||||
labelKeybindMoveRight.SetBackgroundColor(tcell.ColorDefault)
|
||||
labelKeybindSoftDrop := cview.NewTextView().SetText("Soft Drop")
|
||||
labelKeybindSoftDrop.SetBackgroundColor(tcell.ColorDefault)
|
||||
labelKeybindHardDrop := cview.NewTextView().SetText("Hard Drop")
|
||||
labelKeybindHardDrop.SetBackgroundColor(tcell.ColorDefault)
|
||||
|
||||
buttonKeybindRotateCCW = cview.NewButton("Set").SetSelectedFunc(selectTitleFunc(1))
|
||||
buttonKeybindRotateCW = cview.NewButton("Set").SetSelectedFunc(selectTitleFunc(2))
|
||||
buttonKeybindMoveLeft = cview.NewButton("Set").SetSelectedFunc(selectTitleFunc(3))
|
||||
|
@ -306,27 +361,27 @@ func initGUI(skipTitle bool) (*cview.Application, error) {
|
|||
buttonKeybindSave = cview.NewButton("Save").SetSelectedFunc(selectTitleFunc(8))
|
||||
|
||||
rotateCCWGrid := cview.NewGrid().SetColumns(27, -1).
|
||||
AddItem(cview.NewTextView().SetText("Rotate CCW"), 0, 0, 1, 1, 0, 0, false).
|
||||
AddItem(labelKeybindRotateCCW, 0, 0, 1, 1, 0, 0, false).
|
||||
AddItem(buttonKeybindRotateCCW, 0, 1, 1, 1, 0, 0, false)
|
||||
|
||||
rotateCWGrid := cview.NewGrid().SetColumns(27, -1).
|
||||
AddItem(cview.NewTextView().SetText("Rotate CW"), 0, 0, 1, 1, 0, 0, false).
|
||||
AddItem(labelKeybindRotateCW, 0, 0, 1, 1, 0, 0, false).
|
||||
AddItem(buttonKeybindRotateCW, 0, 1, 1, 1, 0, 0, false)
|
||||
|
||||
moveLeftGrid := cview.NewGrid().SetColumns(27, -1).
|
||||
AddItem(cview.NewTextView().SetText("Move Left"), 0, 0, 1, 1, 0, 0, false).
|
||||
AddItem(labelKeybindMoveLeft, 0, 0, 1, 1, 0, 0, false).
|
||||
AddItem(buttonKeybindMoveLeft, 0, 1, 1, 1, 0, 0, false)
|
||||
|
||||
moveRightGrid := cview.NewGrid().SetColumns(27, -1).
|
||||
AddItem(cview.NewTextView().SetText("Move Right"), 0, 0, 1, 1, 0, 0, false).
|
||||
AddItem(labelKeybindMoveRight, 0, 0, 1, 1, 0, 0, false).
|
||||
AddItem(buttonKeybindMoveRight, 0, 1, 1, 1, 0, 0, false)
|
||||
|
||||
softDropGrid := cview.NewGrid().SetColumns(27, -1).
|
||||
AddItem(cview.NewTextView().SetText("Soft Drop"), 0, 0, 1, 1, 0, 0, false).
|
||||
AddItem(labelKeybindSoftDrop, 0, 0, 1, 1, 0, 0, false).
|
||||
AddItem(buttonKeybindSoftDrop, 0, 1, 1, 1, 0, 0, false)
|
||||
|
||||
hardDropGrid := cview.NewGrid().SetColumns(27, -1).
|
||||
AddItem(cview.NewTextView().SetText("Hard Drop"), 0, 0, 1, 1, 0, 0, false).
|
||||
AddItem(labelKeybindHardDrop, 0, 0, 1, 1, 0, 0, false).
|
||||
AddItem(buttonKeybindHardDrop, 0, 1, 1, 1, 0, 0, false)
|
||||
|
||||
gameSettingsSubmitGrid := cview.NewGrid().
|
||||
|
@ -337,6 +392,24 @@ func initGUI(skipTitle bool) (*cview.Application, error) {
|
|||
AddItem(buttonKeybindSave, 0, 3, 1, 1, 0, 0, false).
|
||||
AddItem(pad, 0, 4, 1, 1, 0, 0, false)
|
||||
|
||||
gameSettingsOptionsTitle := cview.NewTextView().
|
||||
SetTextAlign(cview.AlignCenter).
|
||||
SetWrap(false).
|
||||
SetWordWrap(false).SetText("Options")
|
||||
gameSettingsOptionsTitle.SetBackgroundColor(tcell.ColorDefault)
|
||||
|
||||
gameSettingsKeybindsTitle := cview.NewTextView().
|
||||
SetTextAlign(cview.AlignCenter).
|
||||
SetWrap(false).
|
||||
SetWordWrap(false).SetText("Keybindings")
|
||||
gameSettingsKeybindsTitle.SetBackgroundColor(tcell.ColorDefault)
|
||||
|
||||
gameSettingsHelp := cview.NewTextView().
|
||||
SetTextAlign(cview.AlignCenter).
|
||||
SetWrap(false).
|
||||
SetWordWrap(false).SetText("\nPrevious: Shift+Tab - Next: Tab")
|
||||
gameSettingsHelp.SetBackgroundColor(tcell.ColorDefault)
|
||||
|
||||
gameSettingsGrid = cview.NewGrid().
|
||||
SetRows(5, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, -1).
|
||||
SetColumns(-1, 34, -1).
|
||||
|
@ -345,17 +418,11 @@ func initGUI(skipTitle bool) (*cview.Application, error) {
|
|||
AddItem(titleR, 0, 2, 18, 1, 0, 0, false).
|
||||
AddItem(gameSettingsTitle, 1, 1, 1, 1, 0, 0, false).
|
||||
AddItem(pad, 2, 1, 1, 1, 0, 0, false).
|
||||
AddItem(cview.NewTextView().
|
||||
SetTextAlign(cview.AlignCenter).
|
||||
SetWrap(false).
|
||||
SetWordWrap(false).SetText("Options"), 3, 1, 1, 1, 0, 0, false).
|
||||
AddItem(gameSettingsOptionsTitle, 3, 1, 1, 1, 0, 0, false).
|
||||
AddItem(ghostPieceGrid, 4, 1, 1, 1, 0, 0, false).
|
||||
AddItem(ghostPieceGrid, 5, 1, 1, 1, 0, 0, false).
|
||||
AddItem(pad, 6, 1, 1, 1, 0, 0, false).
|
||||
AddItem(cview.NewTextView().
|
||||
SetTextAlign(cview.AlignCenter).
|
||||
SetWrap(false).
|
||||
SetWordWrap(false).SetText("Keybindings"), 7, 1, 1, 1, 0, 0, false).
|
||||
AddItem(gameSettingsKeybindsTitle, 7, 1, 1, 1, 0, 0, false).
|
||||
AddItem(pad, 8, 1, 1, 1, 0, 0, false).
|
||||
AddItem(rotateCCWGrid, 9, 1, 1, 1, 0, 0, false).
|
||||
AddItem(rotateCWGrid, 10, 1, 1, 1, 0, 0, false).
|
||||
|
@ -365,10 +432,7 @@ func initGUI(skipTitle bool) (*cview.Application, error) {
|
|||
AddItem(hardDropGrid, 14, 1, 1, 1, 0, 0, false).
|
||||
AddItem(pad, 15, 1, 1, 1, 0, 0, false).
|
||||
AddItem(gameSettingsSubmitGrid, 16, 1, 1, 1, 0, 0, false).
|
||||
AddItem(cview.NewTextView().
|
||||
SetTextAlign(cview.AlignCenter).
|
||||
SetWrap(false).
|
||||
SetWordWrap(false).SetText("\nPrevious: Shift+Tab - Next: Tab"), 17, 1, 1, 1, 0, 0, false)
|
||||
AddItem(gameSettingsHelp, 17, 1, 1, 1, 0, 0, false)
|
||||
|
||||
titleContainerGrid = cview.NewGrid().SetColumns(-1, 80, -1).SetRows(-1, 24, -1).
|
||||
AddItem(pad, 0, 0, 1, 3, 0, 0, false).
|
||||
|
|
6
go.mod
6
go.mod
|
@ -10,7 +10,7 @@ require (
|
|||
github.com/gliderlabs/ssh v0.2.2
|
||||
github.com/mattn/go-isatty v0.0.12
|
||||
github.com/mattn/go-runewidth v0.0.8 // indirect
|
||||
gitlab.com/tslocum/cview v1.4.1-0.20200122232819-5f880bc2c7e6
|
||||
golang.org/x/crypto v0.0.0-20200117160349-530e935923ad
|
||||
golang.org/x/sys v0.0.0-20200122134326-e047566fdf82 // indirect
|
||||
gitlab.com/tslocum/cview v1.4.2-0.20200128151041-339db80f666d
|
||||
golang.org/x/crypto v0.0.0-20200128174031-69ecbb4d6d5d
|
||||
golang.org/x/sys v0.0.0-20200124204421-9fbb57f87de9 // indirect
|
||||
)
|
||||
|
|
12
go.sum
12
go.sum
|
@ -22,19 +22,19 @@ github.com/mattn/go-runewidth v0.0.8 h1:3tS41NlGYSmhhe/8fhGRzc+z3AYCw1Fe1WAyLuuj
|
|||
github.com/mattn/go-runewidth v0.0.8/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI=
|
||||
github.com/rivo/uniseg v0.1.0 h1:+2KBaVoUmb9XzDsrx/Ct0W/EYOSFf/nWTauy++DprtY=
|
||||
github.com/rivo/uniseg v0.1.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
|
||||
gitlab.com/tslocum/cview v1.4.1-0.20200122232819-5f880bc2c7e6 h1:C0UWplFR3t8+7Wj3M194fMIESyiN2jQBaukstRwRETk=
|
||||
gitlab.com/tslocum/cview v1.4.1-0.20200122232819-5f880bc2c7e6/go.mod h1:QbxliYQa2I32UJH2boP54jq6tnWlgm6yViaFXKGDfuM=
|
||||
gitlab.com/tslocum/cview v1.4.2-0.20200128151041-339db80f666d h1:5rPwwmNYGLcOsyawvAw7m/Jtwp5rAuvLoqVW5k09AP0=
|
||||
gitlab.com/tslocum/cview v1.4.2-0.20200128151041-339db80f666d/go.mod h1:QbxliYQa2I32UJH2boP54jq6tnWlgm6yViaFXKGDfuM=
|
||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||
golang.org/x/crypto v0.0.0-20200117160349-530e935923ad h1:Jh8cai0fqIK+f6nG0UgPW5wFk8wmiMhM3AyciDBdtQg=
|
||||
golang.org/x/crypto v0.0.0-20200117160349-530e935923ad/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
||||
golang.org/x/crypto v0.0.0-20200128174031-69ecbb4d6d5d h1:9FCpayM9Egr1baVnV1SX0H87m+XB0B8S0hAMi99X/3U=
|
||||
golang.org/x/crypto v0.0.0-20200128174031-69ecbb4d6d5d/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
||||
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20190626150813-e07cf5db2756/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200103143344-a1369afcdac7/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200122134326-e047566fdf82 h1:ywK/j/KkyTHcdyYSZNXGjMwgmDSfjglYZ3vStQ/gSCU=
|
||||
golang.org/x/sys v0.0.0-20200122134326-e047566fdf82/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200124204421-9fbb57f87de9 h1:1/DFK4b7JH8DmkqhUk48onnSfrPzImPoVxuomtbT2nk=
|
||||
golang.org/x/sys v0.0.0-20200124204421-9fbb57f87de9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
golang.org/x/text v0.3.2 h1:tW2bmiBqwgJj/UpqtC8EpXEZVYOwU0yG4iWbprSVAcs=
|
||||
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package mino
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"sync"
|
||||
"time"
|
||||
)
|
||||
|
@ -73,12 +72,6 @@ type Piece struct {
|
|||
sync.Mutex `json:"-"`
|
||||
}
|
||||
|
||||
type LockedPiece *Piece
|
||||
|
||||
func (p *Piece) String() string {
|
||||
return fmt.Sprintf("%+v", *p)
|
||||
}
|
||||
|
||||
func NewPiece(m Mino, loc Point) *Piece {
|
||||
p := &Piece{Mino: m, original: m, Point: loc}
|
||||
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
package mino
|
||||
|
||||
import (
|
||||
"log"
|
||||
"testing"
|
||||
)
|
||||
|
||||
type PieceTestData struct {
|
||||
R0 string
|
||||
RR string
|
||||
|
@ -17,10 +12,11 @@ var pieceTestData = []*PieceTestData{
|
|||
{Domino, "(0,-1),(0,0)", Domino, "(0,-1),(0,0)"},
|
||||
}
|
||||
|
||||
// TODO Resolve CCW rotation resulting in different coords than CW rotation before completing test
|
||||
/*
|
||||
func TestPiece(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
// TODO Resolve CCW rotation resulting in different coords than CW rotation before completing test
|
||||
return
|
||||
|
||||
for i, d := range pieceTestData {
|
||||
|
@ -31,7 +27,7 @@ func TestPiece(t *testing.T) {
|
|||
|
||||
p := NewPiece(m, Point{0, 0})
|
||||
if p == nil || p.Mino.String() != d.R0 {
|
||||
t.Errorf("failed to create piece %d %s: got %s", i, d.R0, p)
|
||||
t.Errorf("failed to create piece %d %s: got %+v", i, d.R0, p)
|
||||
}
|
||||
|
||||
for direction := 0; direction <= 1; direction++ {
|
||||
|
@ -67,3 +63,4 @@ func TestPiece(t *testing.T) {
|
|||
log.Println(p)
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
|
Loading…
Reference in a new issue