Skip to content
Snippets Groups Projects
Commit 64fa1ace authored by ForkBench's avatar ForkBench
Browse files

Adding base template, and base structs.

parents
Branches
No related tags found
No related merge requests found
Showing
with 1241 additions and 0 deletions
# Fichiers et répertoires spécifiques à Go
/bin
/pkg
/vendor
# Log files
*.log
# OS-specific files
.DS_Store
Thumbs.db
# IDEs et éditeurs
.idea/
.vscode/
*.swp
*.swo
# Coverage reports
coverage.out
# Node.js / NPM
node_modules/
npm-debug.log
yarn-error.log
.pnp
.pnp.js
# Svelte
public/build/
__sapper__/
.svelte-kit/
# TypeScript
*.tsbuildinfo
# Misc
.DS_Store
.env
.env.local
.env.development.local
.env.test.local
.task
.env.production.local
# Frontend specific
frontend/dist
frontend/bindings
\ No newline at end of file
# Welcome to Your New Wails3 Project!
Congratulations on generating your Wails3 application! This README will guide you through the next steps to get your project up and running.
## Getting Started
1. Navigate to your project directory in the terminal.
2. To run your application in development mode, use the following command:
```
wails3 dev
```
This will start your application and enable hot-reloading for both frontend and backend changes.
3. To build your application for production, use:
```
wails3 build
```
This will create a production-ready executable in the `build` directory.
## Exploring Wails3 Features
Now that you have your project set up, it's time to explore the features that Wails3 offers:
1. **Check out the examples**: The best way to learn is by example. Visit the `examples` directory in the `v3/examples` directory to see various sample applications.
2. **Run an example**: To run any of the examples, navigate to the example's directory and use:
```
go run .
```
Note: Some examples may be under development during the alpha phase.
3. **Explore the documentation**: Visit the [Wails3 documentation](https://v3alpha.wails.io/) for in-depth guides and API references.
4. **Join the community**: Have questions or want to share your progress? Join the [Wails Discord](https://discord.gg/JDdSxwjhGf) or visit the [Wails discussions on GitHub](https://github.com/wailsapp/wails/discussions).
## Project Structure
Take a moment to familiarize yourself with your project structure:
- `frontend/`: Contains your frontend code (HTML, CSS, JavaScript/TypeScript)
- `main.go`: The entry point of your Go backend
- `app.go`: Define your application structure and methods here
- `wails.json`: Configuration file for your Wails project
## Next Steps
1. Modify the frontend in the `frontend/` directory to create your desired UI.
2. Add backend functionality in `main.go`.
3. Use `wails3 dev` to see your changes in real-time.
4. When ready, build your application with `wails3 build`.
Happy coding with Wails3! If you encounter any issues or have questions, don't hesitate to consult the documentation or reach out to the Wails community.
version: '3'
vars:
APP_NAME: "AstroProject"
BIN_DIR: "bin"
VITE_PORT: '{{.WAILS_VITE_PORT | default 9245}}'
tasks:
## -------------------------- Build -------------------------- ##
build:
summary: Builds the application
cmds:
# Build for current OS
- task: build:{{OS}}
# Uncomment to build for specific OSes
# - task: build:linux
# - task: build:windows
# - task: build:darwin
## ------> Windows <-------
build:windows:
summary: Builds the application for Windows
deps:
- task: go:mod:tidy
- task: build:frontend
vars:
BUILD_FLAGS: '{{.BUILD_FLAGS}}'
- task: generate:icons
- task: generate:syso
vars:
ARCH: '{{.ARCH}}'
cmds:
- go build {{.BUILD_FLAGS}} -o {{.BIN_DIR}}/AstroProject.exe
vars:
BUILD_FLAGS: '{{if eq .PRODUCTION "true"}}-tags production -trimpath -ldflags="-w -s -H windowsgui"{{else}}-gcflags=all="-l"{{end}}'
env:
GOOS: windows
CGO_ENABLED: 0
GOARCH: '{{.ARCH | default ARCH}}'
PRODUCTION: '{{.PRODUCTION | default "false"}}'
build:windows:prod:arm64:
summary: Creates a production build of the application
cmds:
- task: build:windows
vars:
ARCH: arm64
PRODUCTION: "true"
build:windows:prod:amd64:
summary: Creates a production build of the application
cmds:
- task: build:windows
vars:
ARCH: amd64
PRODUCTION: "true"
build:windows:debug:arm64:
summary: Creates a debug build of the application
cmds:
- task: build:windows
vars:
ARCH: arm64
build:windows:debug:amd64:
summary: Creates a debug build of the application
cmds:
- task: build:windows
vars:
ARCH: amd64
## ------> Darwin <-------
build:darwin:
summary: Creates a production build of the application
deps:
- task: go:mod:tidy
- task: build:frontend
vars:
BUILD_FLAGS: '{{.BUILD_FLAGS}}'
- task: generate:icons
cmds:
- go build {{.BUILD_FLAGS}} -o {{.BIN_DIR}}/{{.APP_NAME}}
vars:
BUILD_FLAGS: '{{if eq .PRODUCTION "true"}}-tags production -trimpath -ldflags="-w -s"{{else}}-gcflags=all="-l"{{end}}'
env:
GOOS: darwin
CGO_ENABLED: 1
GOARCH: '{{.ARCH | default ARCH}}'
CGO_CFLAGS: "-mmacosx-version-min=10.15"
CGO_LDFLAGS: "-mmacosx-version-min=10.15"
MACOSX_DEPLOYMENT_TARGET: "10.15"
PRODUCTION: '{{.PRODUCTION | default "false"}}'
build:darwin:prod:arm64:
summary: Creates a production build of the application
cmds:
- task: build:darwin
vars:
ARCH: arm64
PRODUCTION: "true"
build:darwin:prod:amd64:
summary: Creates a production build of the application
cmds:
- task: build:darwin
vars:
ARCH: amd64
PRODUCTION: "true"
build:darwin:debug:arm64:
summary: Creates a debug build of the application
cmds:
- task: build:darwin
vars:
ARCH: arm64
build:darwin:debug:amd64:
summary: Creates a debug build of the application
cmds:
- task: build:darwin
vars:
ARCH: amd64
## ------> Linux <-------
build:linux:
summary: Builds the application for Linux
deps:
- task: go:mod:tidy
- task: build:frontend
vars:
BUILD_FLAGS: '{{.BUILD_FLAGS}}'
- task: generate:icons
vars:
ARCH: '{{.ARCH}}'
cmds:
- go build {{.BUILD_FLAGS}} -o {{.BIN_DIR}}/AstroProject
vars:
BUILD_FLAGS: '{{if eq .PRODUCTION "true"}}-tags production -trimpath -ldflags="-w -s"{{else}}-gcflags=all="-l"{{end}}'
env:
GOOS: linux
CGO_ENABLED: 1
GOARCH: '{{.ARCH | default ARCH}}'
PRODUCTION: '{{.PRODUCTION | default "false"}}'
build:linux:prod:arm64:
summary: Creates a production build of the application
cmds:
- task: build:linux
vars:
ARCH: arm64
PRODUCTION: "true"
build:linux:prod:amd64:
summary: Creates a production build of the application
cmds:
- task: build:linux
vars:
ARCH: amd64
PRODUCTION: "true"
build:linux:debug:arm64:
summary: Creates a debug build of the application
cmds:
- task: build:linux
vars:
ARCH: arm64
build:linux:debug:amd64:
summary: Creates a debug build of the application
cmds:
- task: build:linux
vars:
ARCH: amd64
## -------------------------- Package -------------------------- ##
package:
summary: Packages a production build of the application into a bundle
cmds:
# Package for current OS
- task: package:{{OS}}
# Package for specific os/arch
# - task: package:darwin:arm64
# - task: package:darwin:amd64
# - task: package:windows:arm64
# - task: package:windows:amd64
## ------> Windows <------
package:windows:
summary: Packages a production build of the application into a `.exe` bundle
cmds:
- task: create:nsis:installer
vars:
ARCH: '{{.ARCH}}'
vars:
ARCH: '{{.ARCH | default ARCH}}'
package:windows:arm64:
summary: Packages a production build of the application into a `.exe` bundle
cmds:
- task: package:windows
vars:
ARCH: arm64
package:windows:amd64:
summary: Packages a production build of the application into a `.exe` bundle
cmds:
- task: package:windows
vars:
ARCH: amd64
generate:syso:
summary: Generates Windows `.syso` file
dir: build
cmds:
- wails3 generate syso -arch {{.ARCH}} -icon icon.ico -manifest wails.exe.manifest -info info.json -out ../wails.syso
vars:
ARCH: '{{.ARCH | default ARCH}}'
create:nsis:installer:
summary: Creates an NSIS installer
label: "NSIS Installer ({{.ARCH}})"
dir: build/nsis
sources:
- "{{.ROOT_DIR}}\\bin\\{{.APP_NAME}}.exe"
generates:
- "{{.ROOT_DIR}}\\bin\\{{.APP_NAME}}-{{.ARCH}}-installer.exe"
deps:
- task: build:windows
vars:
PRODUCTION: "true"
ARCH: '{{.ARCH}}'
cmds:
- makensis -DARG_WAILS_'{{.ARG_FLAG}}'_BINARY="{{.ROOT_DIR}}\{{.BIN_DIR}}\{{.APP_NAME}}.exe" project.nsi
vars:
ARCH: '{{.ARCH | default ARCH}}'
ARG_FLAG: '{{if eq .ARCH "amd64"}}AMD64{{else}}ARM64{{end}}'
## ------> Darwin <------
package:darwin:
summary: Packages a production build of the application into a `.app` bundle
platforms: [ darwin ]
deps:
- task: build:darwin
vars:
PRODUCTION: "true"
cmds:
- task: create:app:bundle
package:darwin:arm64:
summary: Packages a production build of the application into a `.app` bundle
platforms: [ darwin/arm64 ]
deps:
- task: package:darwin
vars:
ARCH: arm64
package:darwin:amd64:
summary: Packages a production build of the application into a `.app` bundle
platforms: [ darwin/amd64 ]
deps:
- task: package:darwin
vars:
ARCH: amd64
create:app:bundle:
summary: Creates an `.app` bundle
cmds:
- mkdir -p {{.BIN_DIR}}/{{.APP_NAME}}.app/Contents/{MacOS,Resources}
- cp build/icons.icns {{.BIN_DIR}}/{{.APP_NAME}}.app/Contents/Resources
- cp {{.BIN_DIR}}/{{.APP_NAME}} {{.BIN_DIR}}/{{.APP_NAME}}.app/Contents/MacOS
- cp build/Info.plist {{.BIN_DIR}}/{{.APP_NAME}}.app/Contents
## ------> Linux <------
package:linux:
summary: Packages a production build of the application for Linux
platforms: [ linux ]
deps:
- task: build:linux
vars:
PRODUCTION: "true"
cmds:
- task: create:appimage
create:appimage:
summary: Creates an AppImage
dir: build/appimage
platforms: [ linux ]
deps:
- task: build:linux
vars:
PRODUCTION: "true"
- task: generate:linux:dotdesktop
cmds:
# Copy binary + icon to appimage dir
- cp {{.APP_BINARY}} {{.APP_NAME}}
- cp ../appicon.png appicon.png
# Generate AppImage
- wails3 generate appimage -binary {{.APP_NAME}} -icon {{.ICON}} -desktopfile {{.DESKTOP_FILE}} -outputdir {{.OUTPUT_DIR}} -builddir {{.ROOT_DIR}}/build/appimage
vars:
APP_NAME: '{{.APP_NAME}}'
APP_BINARY: '../../bin/{{.APP_NAME}}'
ICON: '../appicon.png'
DESKTOP_FILE: '{{.APP_NAME}}.desktop'
OUTPUT_DIR: '../../bin'
generate:linux:dotdesktop:
summary: Generates a `.desktop` file
dir: build
sources:
- "appicon.png"
generates:
- '{{.ROOT_DIR}}/build/appimage/{{.APP_NAME}}.desktop'
cmds:
- mkdir -p {{.ROOT_DIR}}/build/appimage
# Run `wails3 generate .desktop -help` for all the options
- wails3 generate .desktop -name "{{.APP_NAME}}" -exec "{{.EXEC}}" -icon "{{.ICON}}" -outputfile {{.ROOT_DIR}}/build/appimage/{{.APP_NAME}}.desktop -categories "{{.CATEGORIES}}"
# -comment "A comment"
# -terminal "true"
# -version "1.0"
# -genericname "Generic Name"
# -keywords "keyword1;keyword2;"
# -startupnotify "true"
# -mimetype "application/x-extension1;application/x-extension2;"
vars:
APP_NAME: '{{.APP_NAME}}'
EXEC: '{{.APP_NAME}}'
ICON: 'appicon'
CATEGORIES: 'Development;'
OUTPUTFILE: '{{.ROOT_DIR}}/build/appimage/{{.APP_NAME}}.desktop'
## -------------------------- Misc -------------------------- ##
generate:icons:
summary: Generates Windows `.ico` and Mac `.icns` files from an image
dir: build
sources:
- "appicon.png"
generates:
- "icons.icns"
- "icons.ico"
cmds:
# Generates both .ico and .icns files
- wails3 generate icons -input appicon.png
install:frontend:deps:
summary: Install frontend dependencies
dir: frontend
sources:
- package.json
- package-lock.json
generates:
- node_modules/*
preconditions:
- sh: npm version
msg: "Looks like npm isn't installed. Npm is part of the Node installer: https://nodejs.org/en/download/"
cmds:
# - npm install --silent --no-progress
- npm install
build:frontend:
summary: Build the frontend project
dir: frontend
sources:
- "**/*"
generates:
- dist/*
deps:
- install:frontend:deps
- task: generate:bindings
vars:
BUILD_FLAGS: '{{.BUILD_FLAGS}}'
cmds:
- npm run build -q
generate:bindings:
summary: Generates bindings for the frontend
sources:
- "**/*.go"
- go.mod
- go.sum
generates:
- "frontend/bindings/**/*"
cmds:
# For a complete list of options, run `wails3 generate bindings -help`
- wails3 generate bindings -f '{{.BUILD_FLAGS}}' -ts
go:mod:tidy:
summary: Runs `go mod tidy`
internal: true
generates:
- go.sum
sources:
- go.mod
cmds:
- go mod tidy
# ----------------------- dev ----------------------- #
run:
summary: Runs the application
cmds:
- task: run:{{OS}}
run:windows:
cmds:
- '{{.BIN_DIR}}\\{{.APP_NAME}}.exe'
run:linux:
cmds:
- '{{.BIN_DIR}}/{{.APP_NAME}}'
run:darwin:
cmds:
- '{{.BIN_DIR}}/{{.APP_NAME}}'
dev:frontend:
summary: Runs the frontend in development mode
dir: frontend
deps:
- task: install:frontend:deps
cmds:
- npm run dev -- --port {{.VITE_PORT}} --strictPort
dev:
summary: Runs the application in development mode
cmds:
- wails3 dev -config ./build/devmode.config.yaml -port {{.VITE_PORT}}
dev:reload:
summary: Reloads the application
cmds:
- task: run
This diff is collapsed.
This diff is collapsed.
[
{
"region_name": "AUVERGNE RHONE ALPES",
"region_id": 0
},
{
"region_name": "BOURGOGNE FRANCHE COMTE",
"region_id": 1
},
{
"region_name": "BRETAGNE",
"region_id": 2
},
{
"region_name": "CENTRE VAL DE LOIRE",
"region_id": 3
},
{
"region_name": "CORSE",
"region_id": 4
},
{
"region_name": "FFE",
"region_id": 5
},
{
"region_name": "GRAND EST",
"region_id": 6
},
{
"region_name": "GUADELOUPE",
"region_id": 7
},
{
"region_name": "GUYANE",
"region_id": 8
},
{
"region_name": "HAUTS DE FRANCE",
"region_id": 9
},
{
"region_name": "ILE DE FRANCE",
"region_id": 10
},
{
"region_name": "LA REUNION",
"region_id": 11
},
{
"region_name": "MARTINIQUE",
"region_id": 12
},
{
"region_name": "NORMANDIE",
"region_id": 13
},
{
"region_name": "NOUVELLE AQUITAINE",
"region_id": 14
},
{
"region_name": "NOUVELLE CALEDONIE",
"region_id": 15
},
{
"region_name": "OCCITANIE",
"region_id": 16
},
{
"region_name": "PACA",
"region_id": 17
},
{
"region_name": "PAYS DE LA LOIRE",
"region_id": 18
}
]
\ No newline at end of file
package services
type Nation struct {
NationID uint16 `json:"nation_id"`
NationName string `json:"nation_name"`
NationCode string `json:"nation_code"`
}
type Region struct {
RegionID uint16 `json:"region_id"`
RegionName string `json:"region_name"`
}
type Club struct {
ClubID uint16 `json:"club_id"`
ClubName string `json:"club_name"`
}
func (n *Nation) GetFlagPath() string {
return "https://flagsapi.com/" + n.NationCode + "/flat/64.png"
}
func (r *Nation) Load() []Nation {
return LoadData[Nation]("../resources/nations.json")
}
func (r *Region) Load() []Region {
return LoadData[Region]("../resources/regions.json")
}
func (c *Club) Load() []Club {
return LoadData[Club]("../resources/clubs.json")
}
package services
import "math"
// Competition : Competition details
type Competition struct {
CompetitionID uint8 // 255 competitions max
CompetitionName string
CompetitionCategory Category
CompetitionWeapon Weapon
CompetitionState State
CompetitionMaxStageNumber uint8
CompetitionStages []Stage
CompetitionPlayers []Player
}
func (c Competition) String() string {
return "Competition : " + c.CompetitionName + " - " + c.CompetitionCategory.String() + " - " + c.CompetitionWeapon.String() + " - " + c.CompetitionState.String()
}
func CreateCompetition(competitionID uint8, competitionName string, competitionCategory Category, competitionWeapon Weapon, competitionMaxStageNumber uint8) Competition {
var c Competition
c.CompetitionID = competitionID
c.CompetitionName = competitionName
c.CompetitionCategory = competitionCategory
c.CompetitionWeapon = competitionWeapon
c.CompetitionState = REGISTERING
c.CompetitionMaxStageNumber = competitionMaxStageNumber
c.CompetitionStages = make([]Stage, competitionMaxStageNumber)
return c
}
func (c Competition) AddStage(stage Stage) bool {
if c.CompetitionState != IDLE {
return false
}
if len(c.CompetitionStages) >= int(c.CompetitionMaxStageNumber) {
return false
}
c.CompetitionStages = append(c.CompetitionStages, stage)
return true
}
func (c Competition) StagePosition(stage Stage) uint16 {
for i, competitionStage := range c.CompetitionStages {
if competitionStage == stage {
return uint16(i)
}
}
return math.MaxInt16
}
func (c Competition) RemoveStage(stage Stage) bool {
if c.CompetitionState != IDLE {
return false
}
if c.StagePosition(stage) == math.MaxInt16 {
return false
}
c.CompetitionStages = append(c.CompetitionStages[:c.StagePosition(stage)], c.CompetitionStages[c.StagePosition(stage)+1:]...)
return true
}
func (c Competition) StartCompetition() bool {
if c.CompetitionState != REGISTERING {
return false
}
c.CompetitionState = STARTED
return true
}
func (c Competition) FinishCompetition() bool {
if c.CompetitionState != STARTED {
return false
}
// TODO: Implement competition results
c.CompetitionState = FINISHED
return true
}
func (c Competition) AddPlayer(player Player) bool {
if c.CompetitionState != REGISTERING {
return false
}
c.CompetitionPlayers = append(c.CompetitionPlayers, player)
return true
}
func (c Competition) PlayerPosition(player Player) uint16 {
for i, competitionPlayer := range c.CompetitionPlayers {
if competitionPlayer == player {
return uint16(i)
}
}
return math.MaxInt16
}
func (c Competition) RemovePlayer(player Player) bool {
if c.CompetitionState != REGISTERING {
return false
}
pos := c.PlayerPosition(player)
if pos == math.MaxInt16 {
return false
}
c.CompetitionPlayers = append(c.CompetitionPlayers[:pos], c.CompetitionPlayers[pos+1:]...)
return true
}
func (c Competition) AddPlayerToStage(player Player, stage Stage) bool {
if stage.AddPlayer(player) {
return true
}
return false
}
func (c Competition) RemovePlayerFromStage(player Player, stage Stage) bool {
if stage.RemovePlayer(player) {
return true
}
return false
}
package services
// Player : Person details
type Player struct {
PlayerID uint16 // More than 255 players
PlayerFirstname string
PlayerLastname string
PlayerNationID uint16
PlayerRegionID uint16
PlayerClubID uint16
}
func (p Player) String() string {
return "Player : " + p.PlayerFirstname + " " + p.PlayerLastname
}
// Referee : Person details
type Referee struct {
RefereeID uint16 // More than 255 referees
RefereeFirstname string
RefereeLastname string
RefereeNationID uint16
RefereeRegionID uint16
RefereeClubID uint16
}
func (r Referee) String() string {
return "Referee : " + r.RefereeFirstname + " " + r.RefereeLastname
}
package services
import "math"
type Pool struct {
PoolID uint8 // 255 pools max
PoolState State
PoolMaxSize uint16
PoolPlayers []Player
PoolReferee Referee
}
func (p Pool) String() string {
var s string
s = string(p.PoolID) + " - " + p.PoolState.String()
for _, player := range p.PoolPlayers {
s = s + "\n" + player.String()
}
return s
}
func CreateStage(poolID uint8, poolMaxSize uint16) Pool {
var p Pool
p.PoolID = poolID
p.PoolState = IDLE
p.PoolMaxSize = poolMaxSize
p.PoolPlayers = make([]Player, poolMaxSize)
p.PoolReferee = Referee{}
return p
}
func (p Pool) PlayerPosition(player Player) uint16 {
for i, poolPlayer := range p.PoolPlayers {
if poolPlayer.PlayerID == player.PlayerID {
return uint16(i)
}
}
return math.MaxInt16
}
func (p Pool) AddPlayer(player Player) bool {
if p.PoolState != IDLE {
return false
}
if len(p.PoolPlayers) >= int(p.PoolMaxSize) {
return false
}
if p.PlayerPosition(player) == math.MaxInt16 {
p.PoolPlayers = append(p.PoolPlayers, player)
return true
}
return false
}
func (p Pool) RemovePlayer(player Player) bool {
if p.PoolState != IDLE {
return false
}
pos := p.PlayerPosition(player)
if pos != math.MaxInt16 {
p.PoolPlayers = append(p.PoolPlayers[:pos], p.PoolPlayers[pos+1:]...)
return true
}
return false
}
func (p Pool) SetReferee(referee Referee) {
p.PoolReferee = referee
}
package services
const MinStageSize = 3
// Session : Session details
type Session struct {
Competitions []Competition
CompetitionNumber uint8
}
func (s *Session) AddCompetition(name string, category string, weapon string) {
competition := CreateCompetition(
s.CompetitionNumber,
name,
CreateCategory(category),
CreateWeapon(weapon),
MinStageSize)
s.Competitions = append(s.Competitions, competition)
s.CompetitionNumber++
}
func (s *Session) RemoveCompetition(competitionID uint8) {
for i, competition := range s.Competitions {
if competition.CompetitionID == competitionID {
s.Competitions = append(s.Competitions[:i], s.Competitions[i+1:]...)
}
}
s.CompetitionNumber--
}
func (s *Session) GetCompetitions() []Competition {
return s.Competitions
}
package services
// Stage : Stage details
type Stage interface {
CreateStage(stageID uint8, stageMaxSize uint16) Stage
PlayerPosition(player Player) uint16
AddPlayer(player Player) bool
RemovePlayer(player Player) bool
}
package services
import (
"encoding/json"
"os"
)
// Category : Age category
type Category uint8
const (
U7 Category = iota // 0
U9 // 1
U11 // 2
U13 // 3
U15 // 4
U17 // 5
U20 // 6
SENIOR // 7
VETERAN // 8
)
func (c Category) String() string {
switch c {
case U7:
return "U7"
case U9:
return "U9"
case U11:
return "U11"
case U13:
return "U13"
case U15:
return "U15"
case U17:
return "U17"
case U20:
return "U20"
case SENIOR:
return "Senior"
case VETERAN:
return "Veteran"
default:
return "Unknown"
}
}
func CreateCategory(name string) Category {
switch name {
case "U7":
return U7
case "U9":
return U9
case "U11":
return U11
case "U13":
return U13
case "U15":
return U15
case "U17":
return U17
case "U20":
return U20
case "Senior":
return SENIOR
case "Veteran":
return VETERAN
default:
return SENIOR
}
}
// Weapon : Weapon used in competition
type Weapon uint8
const (
FOIL Weapon = iota // 0
EPEE // 1
SABRE // 2
)
func (w Weapon) String() string {
switch w {
case FOIL:
return "Foil"
case EPEE:
return "Epee"
case SABRE:
return "Sabre"
default:
return "Unknown"
}
}
func CreateWeapon(name string) Weapon {
switch name {
case "Foil":
return FOIL
case "Epee":
return EPEE
case "Sabre":
return SABRE
default:
return FOIL
}
}
// State : Competition state
type State uint8
const (
REGISTERING State = iota // 0
STARTED // 1
FINISHED // 2
IDLE // 3
)
func (s State) String() string {
switch s {
case REGISTERING:
return "Registering"
case STARTED:
return "Started"
case FINISHED:
return "Finished"
case IDLE:
return "Idle"
default:
return "Unknown"
}
}
// ---- Generic JSON loader ----
type loadable interface {
Load()
}
func LoadData[T any](filename string) []T {
// Read the file
jsonFile, err := os.Open(filename)
if err != nil {
panic(err)
}
defer func(jsonFile *os.File) {
err := jsonFile.Close()
if err != nil {
panic(err)
}
}(jsonFile)
// Decode the JSON
var data []T
err = json.NewDecoder(jsonFile).Decode(&data)
if err != nil {
panic(err)
}
return data
}
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleName</key>
<string>My Product</string>
<key>CFBundleExecutable</key>
<string>AstroProject</string>
<key>CFBundleIdentifier</key>
<string>com.wails.astroproject</string>
<key>CFBundleVersion</key>
<string>0.1.0</string>
<key>CFBundleGetInfoString</key>
<string>This is a comment</string>
<key>CFBundleShortVersionString</key>
<string>0.1.0</string>
<key>CFBundleIconFile</key>
<string>icons</string>
<key>LSMinimumSystemVersion</key>
<string>10.13.0</string>
<key>NSHighResolutionCapable</key>
<string>true</string>
<key>NSHumanReadableCopyright</key>
<string>© now, My Company</string>
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsLocalNetworking</key>
<true/>
</dict>
</dict>
</plist>
\ No newline at end of file
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleName</key>
<string>My Product</string>
<key>CFBundleExecutable</key>
<string>AstroProject</string>
<key>CFBundleIdentifier</key>
<string>com.wails.astroproject</string>
<key>CFBundleVersion</key>
<string>0.1.0</string>
<key>CFBundleGetInfoString</key>
<string>This is a comment</string>
<key>CFBundleShortVersionString</key>
<string>0.1.0</string>
<key>CFBundleIconFile</key>
<string>icons</string>
<key>LSMinimumSystemVersion</key>
<string>10.13.0</string>
<key>NSHighResolutionCapable</key>
<string>true</string>
<key>NSHumanReadableCopyright</key>
<string>© now, My Company</string>
</dict>
</plist>
\ No newline at end of file
build/appicon.png

130 KiB

#!/usr/bin/env bash
# Copyright (c) 2018-Present Lea Anthony
# SPDX-License-Identifier: MIT
# Fail script on any error
set -euxo pipefail
# Define variables
APP_DIR="${APP_NAME}.AppDir"
# Create AppDir structure
mkdir -p "${APP_DIR}/usr/bin"
cp -r "${APP_BINARY}" "${APP_DIR}/usr/bin/"
cp "${ICON_PATH}" "${APP_DIR}/"
cp "${DESKTOP_FILE}" "${APP_DIR}/"
# Download linuxdeploy and make it executable
wget -q -4 -N https://github.com/linuxdeploy/linuxdeploy/releases/download/continuous/linuxdeploy-x86_64.AppImage
chmod +x linuxdeploy-x86_64.AppImage
# Run linuxdeploy to bundle the application
./linuxdeploy-x86_64.AppImage --appdir "${APP_DIR}" --output appimage
# Rename the generated AppImage
mv "${APP_NAME}*.AppImage" "${APP_NAME}.AppImage"
config:
root_path: .
log_level: warn
debounce: 1000
ignore:
dir:
- .git
- node_modules
- frontend
- bin
file:
- .DS_Store
- .gitignore
- .gitkeep
watched_extension:
- "*.go"
git_ignore: true
executes:
- cmd: wails3 task install:frontend:deps
type: once
- cmd: wails3 task dev:frontend
type: background
- cmd: go mod tidy
type: blocking
- cmd: wails3 task build
type: blocking
- cmd: wails3 task run
type: primary
build/icon.ico

21.2 KiB

File added
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment