Initial commit
This commit is contained in:
commit
e3287299b2
|
@ -0,0 +1,5 @@
|
|||
.idea/
|
||||
dist/
|
||||
vendor/
|
||||
*.sh
|
||||
cmd/dirt/dirt
|
|
@ -0,0 +1,51 @@
|
|||
# dirt - MUD framework
|
||||
[![Donate](https://img.shields.io/liberapay/receives/rocketnine.space.svg?logo=liberapay)](https://liberapay.com/rocketnine.space)
|
||||
|
||||
This framework is in pre-alpha state. Here be dragons.
|
||||
|
||||
## Features
|
||||
|
||||
- Absolutely nothing right now, but in the future:
|
||||
- Create games without writing any code using mkdirt
|
||||
- Terminal-based
|
||||
- VIM keybindings
|
||||
- Games are stored as .mud files which are played using dirt
|
||||
- Single-player or multiplayer
|
||||
- View map (when enabled)
|
||||
|
||||
## Install
|
||||
|
||||
This application is written in [Go](https://golang.org). Download and install
|
||||
the Go compiler if you have not already done so.
|
||||
|
||||
### Download and install dirt to ~/go/bin/dirt
|
||||
|
||||
```bash
|
||||
go get code.rocketnine.space/tslocum/cmd/dirt
|
||||
```
|
||||
|
||||
### Download and install mkdirt to ~/go/bin/mkdirt
|
||||
|
||||
```bash
|
||||
go get code.rocketnine.space/tslocum/cmd/mkdirt
|
||||
```
|
||||
|
||||
## Run
|
||||
|
||||
```bash
|
||||
# Create a game using mkdirt
|
||||
mkdirt
|
||||
|
||||
# Distribute it and play it using dirt
|
||||
dirt my-game.mud
|
||||
```
|
||||
|
||||
## Support
|
||||
|
||||
Please share issues and suggestions [here](https://gitlab.com/tslocum/dirt/issues).
|
||||
|
||||
## Contribute
|
||||
|
||||
1. Fork this repository.
|
||||
2. Commit code changes to your forked repository.
|
||||
3. Submit a pull request describing your changes.
|
|
@ -0,0 +1 @@
|
|||
package dirt
|
|
@ -0,0 +1,19 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"code.rocketnine.space/tslocum/cview"
|
||||
)
|
||||
|
||||
func main() {
|
||||
app := cview.NewApplication()
|
||||
|
||||
tv := cview.NewTextView()
|
||||
tv.SetText("test")
|
||||
|
||||
app.SetRoot(tv, true)
|
||||
|
||||
err := app.Run()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
|
@ -0,0 +1,19 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"code.rocketnine.space/tslocum/cview"
|
||||
"code.rocketnine.space/tslocum/dirt"
|
||||
)
|
||||
|
||||
func main() {
|
||||
app := cview.NewApplication()
|
||||
|
||||
ui := dirt.NewUI()
|
||||
|
||||
app.SetRoot(ui.Build(), true)
|
||||
|
||||
err := app.Run()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
|
@ -0,0 +1 @@
|
|||
package fullgame
|
|
@ -0,0 +1,5 @@
|
|||
module code.rocketnine.space/tslocum/dirt
|
||||
|
||||
go 1.16
|
||||
|
||||
require code.rocketnine.space/tslocum/cview v1.5.5-0.20210425060849-1653d59d6bf9
|
|
@ -0,0 +1,31 @@
|
|||
code.rocketnine.space/tslocum/cbind v0.1.5 h1:i6NkeLLNPNMS4NWNi3302Ay3zSU6MrqOT+yJskiodxE=
|
||||
code.rocketnine.space/tslocum/cbind v0.1.5/go.mod h1:LtfqJTzM7qhg88nAvNhx+VnTjZ0SXBJtxBObbfBWo/M=
|
||||
code.rocketnine.space/tslocum/cview v1.5.5-0.20210425060849-1653d59d6bf9 h1:sh4L2GdaHbgKfc44fnFKbvrGgOz6vm5hR/ac44ca4OU=
|
||||
code.rocketnine.space/tslocum/cview v1.5.5-0.20210425060849-1653d59d6bf9/go.mod h1:peg3a4WKQcs2Xyq3vM5IzvUksUUEZMBksuOpoS/V/rU=
|
||||
github.com/gdamore/encoding v1.0.0 h1:+7OoQ1Bc6eTm5niUzBa0Ctsh6JbMW6Ra+YNuAtDBdko=
|
||||
github.com/gdamore/encoding v1.0.0/go.mod h1:alR0ol34c49FCSBLjhosxzcPHQbf2trDkoo5dl+VrEg=
|
||||
github.com/gdamore/tcell/v2 v2.2.0/go.mod h1:cTTuF84Dlj/RqmaCIV5p4w8uG1zWdk0SF6oBpwHp4fU=
|
||||
github.com/gdamore/tcell/v2 v2.2.1 h1:Gt8wk0jd5pIK2CyXNo/fqwxNWf726j1lQjEDdfbnqTc=
|
||||
github.com/gdamore/tcell/v2 v2.2.1/go.mod h1:cTTuF84Dlj/RqmaCIV5p4w8uG1zWdk0SF6oBpwHp4fU=
|
||||
github.com/lucasb-eyer/go-colorful v1.0.3/go.mod h1:R4dSotOR9KMtayYi1e77YzuveK+i7ruzyGqttikkLy0=
|
||||
github.com/lucasb-eyer/go-colorful v1.2.0 h1:1nnpGOrhyZZuNyfu1QjKiUICQ74+3FNCN69Aj6K7nkY=
|
||||
github.com/lucasb-eyer/go-colorful v1.2.0/go.mod h1:R4dSotOR9KMtayYi1e77YzuveK+i7ruzyGqttikkLy0=
|
||||
github.com/mattn/go-runewidth v0.0.10/go.mod h1:RAqKPSqVFrSLVXbA8x7dzmKdmGzieGRCM46jaSJTDAk=
|
||||
github.com/mattn/go-runewidth v0.0.12 h1:Y41i/hVW3Pgwr8gV+J23B9YEY0zxjptBuCWEaxmAOow=
|
||||
github.com/mattn/go-runewidth v0.0.12/go.mod h1:RAqKPSqVFrSLVXbA8x7dzmKdmGzieGRCM46jaSJTDAk=
|
||||
github.com/rivo/uniseg v0.1.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
|
||||
github.com/rivo/uniseg v0.2.0 h1:S1pD9weZBuJdFmowNwbpi7BJ8TNftyUImj/0WQi72jY=
|
||||
github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
|
||||
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210309040221-94ec62e08169/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210423082822-04245dca01da h1:b3NXsE2LusjYGGjL5bxEVZZORm/YEFFrWFjR8eFrw/c=
|
||||
golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/term v0.0.0-20201210144234-2321bbc49cbf/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
||||
golang.org/x/term v0.0.0-20210220032956-6a3ed077a48d/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
||||
golang.org/x/term v0.0.0-20210422114643-f5beecf764ed h1:Ei4bQjjpYUsS4efOUz+5Nz++IVkHk87n2zBA0NxBWc0=
|
||||
golang.org/x/term v0.0.0-20210422114643-f5beecf764ed/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||
golang.org/x/text v0.3.6 h1:aRYxNxv6iGQlyVaZmk6ZgYEDa+Jg18DxebPSrd6bg1M=
|
||||
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
|
@ -0,0 +1 @@
|
|||
package dirt
|
|
@ -0,0 +1,56 @@
|
|||
package dirt
|
||||
|
||||
import "code.rocketnine.space/tslocum/cview"
|
||||
|
||||
const (
|
||||
ElementNone = iota
|
||||
ElementText
|
||||
)
|
||||
|
||||
type TextData struct {
|
||||
Text string
|
||||
}
|
||||
|
||||
type UI struct {
|
||||
Rows []int
|
||||
Columns []int
|
||||
Elements []int
|
||||
Layout [][4]int // x, y, columns, rows
|
||||
Data []interface{}
|
||||
}
|
||||
|
||||
func NewUI() *UI {
|
||||
return DefaultUI()
|
||||
}
|
||||
|
||||
func DefaultUI() *UI {
|
||||
return &UI{
|
||||
Elements: []int{ElementText},
|
||||
Layout: [][4]int{{0, 0, 1, 1}},
|
||||
Data: []interface{}{&TextData{Text: "Example text element"}},
|
||||
}
|
||||
}
|
||||
|
||||
func (u *UI) Build() *cview.Grid {
|
||||
g := cview.NewGrid()
|
||||
|
||||
g.SetRows(u.Rows...)
|
||||
|
||||
g.SetColumns(u.Columns...)
|
||||
|
||||
for i, t := range u.Elements {
|
||||
var e cview.Primitive
|
||||
e = cview.NewBox()
|
||||
|
||||
if t == ElementText {
|
||||
tv := cview.NewTextView()
|
||||
d := u.Data[i].(*TextData)
|
||||
tv.SetText(d.Text)
|
||||
|
||||
e = tv
|
||||
}
|
||||
|
||||
g.AddItem(e, u.Layout[i][1], u.Layout[i][0], u.Layout[i][3], u.Layout[i][2], 0, 0, true)
|
||||
}
|
||||
return g
|
||||
}
|
Loading…
Reference in New Issue