Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
TrevinTeacutter committed Feb 4, 2024
0 parents commit b5e4c3d
Show file tree
Hide file tree
Showing 28 changed files with 2,040 additions and 0 deletions.
34 changes: 34 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# If you prefer the allow list template instead of the deny list, see community template:
# /~https://github.com/github/gitignore/blob/main/community/Golang/Go.AllowList.gitignore
#
# Binaries for programs and plugins
*.exe
*.exe~
*.dll
*.so
*.dylib

# Test binary, built with `go test -c`
*.test

# Output of the go coverage tool, specifically when used with LiteIDE
*.out

# Dependency directories (remove the comment below to include it)
vendor/

# Go workspace file
go.work
go.work.sum

# Local IDE
.vscode/
.idea/

# Local Config
configuration.yaml

# BEGONE DS STORE
**/.DS_Store

dist/
7 changes: 7 additions & 0 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Copyright 2024 - Trevin Teacutter

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
8 changes: 8 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
build:
go build -ldflags "\
-s -w \
-X github.com/trevinteacutter/mwo-helper/pkg/build.Build=v0.1.0 \
-X github.com/trevinteacutter/mwo-helper/pkg/build.Commit=$(git rev-parse HEAD) \
-X github.com/trevinteacutter/mwo-helper/pkg/build.Date=Never \
-X github.com/trevinteacutter/mwo-helper/pkg/build.Runtime=$(go version | awk '{print $3;}') \
" -o helper cmd/helper/main.go
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# MWO Helper

Meant to be a one-stop shop for MWO comp related activities, without the need for a website.
31 changes: 31 additions & 0 deletions cmd/helper/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package main

import (
"flag"
"log"
"os"

"gioui.org/app"
"gioui.org/unit"

"github.com/trevinteacutter/mwo-helper/internal/cmd/helper"
)

func main() {
flag.Parse()

go func() {
window := app.NewWindow(
app.Title("MWO Helper"),
app.Size(unit.Dp(1280), unit.Dp(720)),
)

if err := helper.Loop(window); err != nil {
log.Panic(err)
}

os.Exit(0)
}()

app.Main()
}
22 changes: 22 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
module github.com/trevinteacutter/mwo-helper

go 1.21

require (
gioui.org v0.4.2-0.20240126204013-05d28ad76a49
gioui.org/x v0.4.1-0.20240125154805-63894e7a18f8
github.com/go-resty/resty/v2 v2.11.0
github.com/mattn/go-sqlite3 v1.14.22
golang.org/x/exp/shiny v0.0.0-20240119083558-1b970713d09a
)

require (
gioui.org/cpu v0.0.0-20220412190645-f1e9e8c3b1f7 // indirect
gioui.org/shader v1.0.8 // indirect
github.com/go-text/typesetting v0.0.0-20230803102845-24e03d8b5372 // indirect
golang.org/x/exp v0.0.0-20240119083558-1b970713d09a // indirect
golang.org/x/image v0.15.0 // indirect
golang.org/x/net v0.20.0 // indirect
golang.org/x/sys v0.16.0 // indirect
golang.org/x/text v0.14.0 // indirect
)
72 changes: 72 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
eliasnaur.com/font v0.0.0-20230308162249-dd43949cb42d h1:ARo7NCVvN2NdhLlJE9xAbKweuI9L6UgfTbYb0YwPacY=
eliasnaur.com/font v0.0.0-20230308162249-dd43949cb42d/go.mod h1:OYVuxibdk9OSLX8vAqydtRPP87PyTFcT9uH3MlEGBQA=
gioui.org v0.4.2-0.20240126204013-05d28ad76a49 h1:1Ze4VNMZVZ43IJeBQ5vLkRRjpvGx9dXqC5EeyxXK+HU=
gioui.org v0.4.2-0.20240126204013-05d28ad76a49/go.mod h1:2atiYR4upH71/6ehnh6XsUELa7JZOrOHHNMDxGBZF0Q=
gioui.org/cpu v0.0.0-20210808092351-bfe733dd3334/go.mod h1:A8M0Cn5o+vY5LTMlnRoK3O5kG+rH0kWfJjeKd9QpBmQ=
gioui.org/cpu v0.0.0-20220412190645-f1e9e8c3b1f7 h1:tNJdnP5CgM39PRc+KWmBRRYX/zJ+rd5XaYxY5d5veqA=
gioui.org/cpu v0.0.0-20220412190645-f1e9e8c3b1f7/go.mod h1:A8M0Cn5o+vY5LTMlnRoK3O5kG+rH0kWfJjeKd9QpBmQ=
gioui.org/shader v1.0.8 h1:6ks0o/A+b0ne7RzEqRZK5f4Gboz2CfG+mVliciy6+qA=
gioui.org/shader v1.0.8/go.mod h1:mWdiME581d/kV7/iEhLmUgUK5iZ09XR5XpduXzbePVM=
gioui.org/x v0.4.1-0.20240125154805-63894e7a18f8 h1:KPMLwGPGq1Jy66Jfl1CR82NuTBkg4LDqOX5xxz53cF8=
gioui.org/x v0.4.1-0.20240125154805-63894e7a18f8/go.mod h1:yTvnUyvNWPBsKSAgyL3HICzNTwBn9Z12dWmGMPohOnI=
github.com/go-resty/resty/v2 v2.11.0 h1:i7jMfNOJYMp69lq7qozJP+bjgzfAzeOhuGlyDrqxT/8=
github.com/go-resty/resty/v2 v2.11.0/go.mod h1:iiP/OpA0CkcL3IGt1O0+/SIItFUbkkyw5BGXiVdTu+A=
github.com/go-text/typesetting v0.0.0-20230803102845-24e03d8b5372 h1:FQivqchis6bE2/9uF70M2gmmLpe82esEm2QadL0TEJo=
github.com/go-text/typesetting v0.0.0-20230803102845-24e03d8b5372/go.mod h1:evDBbvNR/KaVFZ2ZlDSOWWXIUKq0wCOEtzLxRM8SG3k=
github.com/go-text/typesetting-utils v0.0.0-20230616150549-2a7df14b6a22 h1:LBQTFxP2MfsyEDqSKmUBZaDuDHN1vpqDyOZjcqS7MYI=
github.com/go-text/typesetting-utils v0.0.0-20230616150549-2a7df14b6a22/go.mod h1:DDxDdQEnB70R8owOx3LVpEFvpMK9eeH1o2r0yZhFI9o=
github.com/mattn/go-sqlite3 v1.14.22 h1:2gZY6PC6kBnID23Tichd1K+Z0oS6nE/XwU+Vz/5o4kU=
github.com/mattn/go-sqlite3 v1.14.22/go.mod h1:Uh1q+B4BYcTPb+yiD3kU8Ct7aC0hY9fxUwlHK0RXw+Y=
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
golang.org/x/crypto v0.14.0/go.mod h1:MVFd36DqK4CsrnJYDkBA3VC4m2GkXAM0PvzMCn4JQf4=
golang.org/x/exp v0.0.0-20240119083558-1b970713d09a h1:Q8/wZp0KX97QFTc2ywcOE0YRjZPVIx+MXInMzdvQqcA=
golang.org/x/exp v0.0.0-20240119083558-1b970713d09a/go.mod h1:idGWGoKP1toJGkd5/ig9ZLuPcZBC3ewk7SzmH0uou08=
golang.org/x/exp/shiny v0.0.0-20240119083558-1b970713d09a h1:NZ9mAQhIcCceDZKqQX3JJVIz7nn3QLDuC+nXedsViBM=
golang.org/x/exp/shiny v0.0.0-20240119083558-1b970713d09a/go.mod h1:3F+MieQB7dRYLTmnncoFbb1crS5lfQoTfDgQy6K4N0o=
golang.org/x/image v0.15.0 h1:kOELfmgrmJlw4Cdb7g/QGuB3CvDrXbqEIww/pNtNBm8=
golang.org/x/image v0.15.0/go.mod h1:HUYqC05R2ZcZ3ejNQsIHQDQiwWM4JBqmm6MKANTp4LE=
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg=
golang.org/x/net v0.17.0/go.mod h1:NxSsAGuq816PNPmqtQdLE42eU2Fs7NoRIZrHJAlaCOE=
golang.org/x/net v0.20.0 h1:aCL9BSgETF1k+blQaYUBx9hJ9LOGP3gAVemcZlf1Kpo=
golang.org/x/net v0.20.0/go.mod h1:z8BVo6PvndSri0LbOE3hAn0apkU+1YvI6E70E9jsnvY=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.16.0 h1:xWw16ngr6ZMtmxDyKyIgsE93KNKz5HKmMa3b8ALHidU=
golang.org/x/sys v0.16.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k=
golang.org/x/term v0.8.0/go.mod h1:xPskH00ivmX89bAKVGSKKtLOWNx2+17Eiy94tnKShWo=
golang.org/x/term v0.13.0/go.mod h1:LTmsnFJwVN6bCy1rVCoS+qHT1HhALEFxKncY3WNNh4U=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8=
golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE=
golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ=
golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
golang.org/x/time v0.3.0 h1:rg5rLMjNzMS1RkNLzCG38eapWhnYLFYXDXj2gOlr8j4=
golang.org/x/time v0.3.0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
54 changes: 54 additions & 0 deletions internal/cmd/helper/cmd.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
package helper

import (
"gioui.org/app"
"gioui.org/font/gofont"
"gioui.org/io/system"
"gioui.org/layout"
"gioui.org/op"
"gioui.org/text"
"gioui.org/widget/material"

"github.com/trevinteacutter/mwo-helper/pkg/pages"
"github.com/trevinteacutter/mwo-helper/pkg/pages/about"
"github.com/trevinteacutter/mwo-helper/pkg/pages/home"
"github.com/trevinteacutter/mwo-helper/pkg/pages/isc"
"github.com/trevinteacutter/mwo-helper/pkg/pages/matches"
"github.com/trevinteacutter/mwo-helper/pkg/pages/pilots"
"github.com/trevinteacutter/mwo-helper/pkg/pages/series"
"github.com/trevinteacutter/mwo-helper/pkg/pages/settings"
"github.com/trevinteacutter/mwo-helper/pkg/pages/teams"
)

func Loop(window *app.Window) error {
// database := Load()
//
// defer database.Close()

theme := material.NewTheme()
theme.Shaper = text.NewShaper(text.WithCollection(gofont.Collection()))

var ops op.Ops

router := pages.NewRouter()
router.Register(0, home.New())
router.Register(1, teams.New())
router.Register(2, pilots.New())
router.Register(3, series.New())
router.Register(4, matches.New())
router.Register(5, isc.New())
router.Register(6, settings.New())
router.Register(7, about.New())

for {
switch event := window.NextEvent().(type) {
case system.DestroyEvent:
return event.Err
case system.FrameEvent:
gtx := layout.NewContext(&ops, event)

router.Layout(gtx, theme)
event.Frame(gtx.Ops)
}
}
}
64 changes: 64 additions & 0 deletions internal/cmd/helper/sql.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
package helper

import (
"database/sql"
"log"

_ "github.com/mattn/go-sqlite3"
)

const (
file = "foo.db"
)

func Load() *sql.DB {
database, err := sql.Open("sqlite3", file)
if err != nil {
Setup()
}

return database
}

func Setup() {
database, err := sql.Open("sqlite3", file)
if err != nil {
log.Panic(err)
}

defer database.Close()

sqlStmt := `
create table teams (id integer not null primary key, name text);
create table players (id integer not null primary key, name text);
create table match (id integer not null primary key, name text);
create table series (id integer not null primary key, name text);
create table matchplayer (id integer not null primary key, name text);
`

_, err = database.Exec(sqlStmt)
if err != nil {
log.Printf("%q: %s\n", err, sqlStmt)
return
}

// transaction, err := database.Begin()
// if err != nil {
// log.Fatal(err)
// }
// statement, err := transaction.Prepare("insert into foo(id, name) values(?, ?)")
// if err != nil {
// log.Fatal(err)
// }
// defer statement.Close()
// for i := 0; i < 100; i++ {
// _, err = statement.Exec(i, fmt.Sprintf("こんにちは世界%03d", i))
// if err != nil {
// log.Fatal(err)
// }
// }
// err = transaction.Commit()
// if err != nil {
// log.Fatal(err)
// }
}
40 changes: 40 additions & 0 deletions pkg/applayout/applayout.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package applayout

import (
"gioui.org/layout"
"gioui.org/unit"
)

// DetailRow lays out two widgets in a horizontal row, with the left
// widget considered the "Primary" widget.
type DetailRow struct {
// PrimaryWidth is the fraction of the available width that should
// be allocated to the primary widget. It should be in the range
// (0,1.0]. Defaults to 0.3 if not set.
PrimaryWidth float32
// Inset is automatically applied to both widgets. This inset is
// required, and will default to a uniform 8DP inset if not set.
layout.Inset
}

var DefaultInset = layout.UniformInset(unit.Dp(8))

// Layout the DetailRow with the provided widgets.
func (d DetailRow) Layout(gtx layout.Context, primary, detail layout.Widget) layout.Dimensions {
if d.PrimaryWidth == 0 {
d.PrimaryWidth = 0.3
}

if d.Inset == (layout.Inset{}) {
d.Inset = DefaultInset
}

return layout.Flex{Alignment: layout.Middle}.Layout(gtx,
layout.Flexed(d.PrimaryWidth, func(gtx layout.Context) layout.Dimensions {
return d.Inset.Layout(gtx, primary)
}),
layout.Flexed(1-d.PrimaryWidth, func(gtx layout.Context) layout.Dimensions {
return d.Inset.Layout(gtx, detail)
}),
)
}
21 changes: 21 additions & 0 deletions pkg/build/values.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// Package build is just a package of variables set at build time to store build information.
package build

var (
//nolint: gochecknoglobals // There are set at build time, so they are global and cannot be constants unfortunately.
Build = "snapshot"
//nolint: gochecknoglobals // There are set at build time, so they are global and cannot be constants unfortunately.
Commit = ""
//nolint: gochecknoglobals // There are set at build time, so they are global and cannot be constants unfortunately.
Date = ""
//nolint: gochecknoglobals // There are set at build time, so they are global and cannot be constants unfortunately.
Runtime = ""
//nolint: gochecknoglobals // There are set at build time, so they are global and cannot be constants unfortunately.
OS = ""
//nolint: gochecknoglobals // There are set at build time, so they are global and cannot be constants unfortunately.
Architecture = ""
//nolint: gochecknoglobals // There are set at build time, so they are global and cannot be constants unfortunately.
ARM = ""
//nolint: gochecknoglobals // There are set at build time, so they are global and cannot be constants unfortunately.
AMD64 = ""
)
Loading

0 comments on commit b5e4c3d

Please sign in to comment.