Compare commits
22 Commits
be35430727
...
develop
| Author | SHA1 | Date | |
|---|---|---|---|
| 06503ce518 | |||
| f8932166bb | |||
| ffd41348a0 | |||
|
|
ff6381575e | ||
|
|
acb4401e37 | ||
| 76d8c1744a | |||
|
|
b2bef77f09 | ||
| 4cbb0666cb | |||
| 83cb34001f | |||
| 1f09482950 | |||
| 1af4d225b5 | |||
| 7863c53280 | |||
|
|
35d888ec62 | ||
|
|
15e317b6fe | ||
| 07f11c7d22 | |||
|
|
7c28081b65 | ||
| d9a75a5e21 | |||
|
|
5da6636dd7 | ||
| b04e653350 | |||
|
|
8469610328 | ||
| 9703682b4a | |||
| e281fbafdb |
@@ -19,6 +19,11 @@ jobs:
|
|||||||
check-latest: true
|
check-latest: true
|
||||||
cache: true
|
cache: true
|
||||||
|
|
||||||
|
- name: Setup OS dependencies
|
||||||
|
run: |
|
||||||
|
apt-get update
|
||||||
|
apt-get install -y gcc-mingw-w64 gcc libgl1-mesa-dev xorg-dev
|
||||||
|
|
||||||
- name: Install go dependencies
|
- name: Install go dependencies
|
||||||
run: go mod tidy
|
run: go mod tidy
|
||||||
|
|
||||||
@@ -90,8 +95,9 @@ jobs:
|
|||||||
|
|
||||||
- name: Build for linux
|
- name: Build for linux
|
||||||
run: |
|
run: |
|
||||||
fyne package --appBuild=${BUILD} --exe bin/swiped-mod-switcher-${VERSION}.${BUILD}-${GOOS}-${GOARCH}${EXE} main.go
|
fyne build --os=${GOOS} --metadata BuildVersion=${VERSION} --metadata BuildNumber=${BUILD} -o bin/swiped-mod-switcher-${VERSION}.${BUILD}-${GOOS}-${GOARCH}
|
||||||
env:
|
env:
|
||||||
|
VERSION: ${{github.ref_name}}
|
||||||
BUILD: ${{github.run_number}}
|
BUILD: ${{github.run_number}}
|
||||||
GOOS: linux
|
GOOS: linux
|
||||||
GOARCH: amd64
|
GOARCH: amd64
|
||||||
@@ -101,17 +107,18 @@ jobs:
|
|||||||
|
|
||||||
- name: Build for windows
|
- name: Build for windows
|
||||||
run: |
|
run: |
|
||||||
fyne package --appBuild=${BUILD} --exe bin/swiped-mod-switcher-${VERSION}.${BUILD}-${GOOS}-${GOARCH}${EXE} main.go
|
fyne build --os=${GOOS} --metadata BuildVersion=${VERSION} --metadata BuildNumber=${BUILD} -o bin/swiped-mod-switcher-${VERSION}.${BUILD}-${GOOS}-${GOARCH}.exe
|
||||||
env:
|
env:
|
||||||
|
VERSION: ${{github.ref_name}}
|
||||||
BUILD: ${{github.run_number}}
|
BUILD: ${{github.run_number}}
|
||||||
GOOS: windows
|
GOOS: windows
|
||||||
GOARCH: amd64
|
GOARCH: amd64
|
||||||
EXE: .exe
|
EXE: ".exe"
|
||||||
CGO_ENABLED: 1
|
CGO_ENABLED: 1
|
||||||
CC: x86_64-w64-mingw32-gcc
|
CC: x86_64-w64-mingw32-gcc
|
||||||
|
|
||||||
- name: Upload artifact
|
- name: Upload artifact
|
||||||
uses: actions/upload-artifact@v3
|
uses: actions/upload-artifact@v3
|
||||||
with:
|
with:
|
||||||
name: swiped-mod-switcher-${{github.ref_name}}
|
name: swiped-mod-switcher-${{github.ref_name}}-${{github.run_number}}
|
||||||
path: bin/
|
path: bin/
|
||||||
@@ -20,6 +20,11 @@ jobs:
|
|||||||
check-latest: true
|
check-latest: true
|
||||||
cache: true
|
cache: true
|
||||||
|
|
||||||
|
- name: Setup OS dependencies
|
||||||
|
run: |
|
||||||
|
apt-get update
|
||||||
|
apt-get install -y gcc-mingw-w64 gcc libgl1-mesa-dev xorg-dev
|
||||||
|
|
||||||
- name: Install go dependencies
|
- name: Install go dependencies
|
||||||
run: go mod tidy
|
run: go mod tidy
|
||||||
|
|
||||||
@@ -89,18 +94,32 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
go mod tidy
|
go mod tidy
|
||||||
|
|
||||||
- name: Build
|
- name: Build for linux
|
||||||
run: |
|
run: |
|
||||||
GOOS=linux GOARCH=amd64 CGO_ENABLED=1 CC=gcc fyne package -os=linux -appBuild=${BUILD} -exe bin/swiped-mod-switcher-${VERSION#v}.${BUILD}-linux-amd64 main.go
|
fyne build --os=${GOOS} --metadata BuildVersion=${VERSION} --metadata BuildNumber=${BUILD} -o bin/swiped-mod-switcher-${VERSION}.${BUILD}-${GOOS}-${GOARCH}
|
||||||
cp *.tar.xz bin/
|
ls bin
|
||||||
GOOS=windows GOARCH=amd64 CGO_ENABLED=1 CC=x86_64-w64-mingw32-gcc fyne package -os=windows -appBuild=${BUILD} -exe bin/swiped-mod-switcher-${VERSION#v}.${BUILD}-windows-amd64.exe main.go
|
|
||||||
ls
|
|
||||||
env:
|
env:
|
||||||
VERSION: ${{github.ref_name}}
|
VERSION: ${{github.ref_name}}
|
||||||
BUILD: ${{github.run_number}}
|
BUILD: ${{github.run_number}}
|
||||||
|
GOOS: linux
|
||||||
|
GOARCH: amd64
|
||||||
|
CGO_ENABLED: 1
|
||||||
|
CC: gcc
|
||||||
|
|
||||||
|
- name: Build for windows
|
||||||
|
run: |
|
||||||
|
fyne build --os=${GOOS} --metadata BuildVersion=${VERSION} --metadata BuildNumber=${BUILD} -o bin/swiped-mod-switcher-${VERSION}.${BUILD}-${GOOS}-${GOARCH}.exe
|
||||||
|
ls bin
|
||||||
|
env:
|
||||||
|
VERSION: ${{github.ref_name}}
|
||||||
|
BUILD: ${{github.run_number}}
|
||||||
|
GOOS: windows
|
||||||
|
GOARCH: amd64
|
||||||
|
CGO_ENABLED: 1
|
||||||
|
CC: x86_64-w64-mingw32-gcc
|
||||||
|
|
||||||
- name: Upload artifact
|
- name: Upload artifact
|
||||||
uses: actions/upload-artifact@v3
|
uses: actions/upload-artifact@v3
|
||||||
with:
|
with:
|
||||||
name: swiped-mod-switcher-${{github.ref_name}}
|
name: swiped-mod-switcher-${{github.ref_name}}-${{github.run_number}}
|
||||||
path: bin/
|
path: bin/
|
||||||
@@ -21,6 +21,11 @@ jobs:
|
|||||||
check-latest: true
|
check-latest: true
|
||||||
cache: true
|
cache: true
|
||||||
|
|
||||||
|
- name: Setup OS dependencies
|
||||||
|
run: |
|
||||||
|
apt-get update
|
||||||
|
apt-get install -y gcc-mingw-w64 gcc libgl1-mesa-dev xorg-dev
|
||||||
|
|
||||||
- name: Install go dependencies
|
- name: Install go dependencies
|
||||||
run: go mod tidy
|
run: go mod tidy
|
||||||
|
|
||||||
@@ -87,7 +92,7 @@ jobs:
|
|||||||
|
|
||||||
- name: Build for linux
|
- name: Build for linux
|
||||||
run: |
|
run: |
|
||||||
fyne package --os ${{GOOS}} --release --appVersion=${VERSION#v} --appBuild=${BUILD} --exe bin/sw1ped-mod-switcher-${VERSION#v}.${BUILD}-linux-amd64 main.go
|
fyne build --release --os=${GOOS} --metadata BuildVersion=${VERSION} --metadata BuildNumber=${BUILD} -o bin/swiped-mod-switcher-${VERSION#v}.${BUILD}-${GOOS}-${GOARCH}
|
||||||
env:
|
env:
|
||||||
VERSION: ${{github.ref_name}}
|
VERSION: ${{github.ref_name}}
|
||||||
BUILD: ${{github.run_number}}
|
BUILD: ${{github.run_number}}
|
||||||
@@ -97,10 +102,9 @@ jobs:
|
|||||||
CGO_ENABLED: 1
|
CGO_ENABLED: 1
|
||||||
CC: gcc
|
CC: gcc
|
||||||
|
|
||||||
|
|
||||||
- name: Build for windows
|
- name: Build for windows
|
||||||
run: |
|
run: |
|
||||||
fyne package --os ${{GOOS}} --release --appVersion=${VERSION#v} --appBuild=${BUILD} --exe bin/sw1ped-mod-switcher-${VERSION#v}.${BUILD}-windows-amd64.exe main.go
|
fyne build --release --os=${GOOS} --metadata BuildVersion=${VERSION} --metadata BuildNumber=${BUILD} -o bin/swiped-mod-switcher-${VERSION#v}.${BUILD}-${GOOS}-${GOARCH}.exe
|
||||||
env:
|
env:
|
||||||
VERSION: ${{github.ref_name}}
|
VERSION: ${{github.ref_name}}
|
||||||
BUILD: ${{github.run_number}}
|
BUILD: ${{github.run_number}}
|
||||||
@@ -110,10 +114,15 @@ jobs:
|
|||||||
CGO_ENABLED: 1
|
CGO_ENABLED: 1
|
||||||
CC: x86_64-w64-mingw32-gcc
|
CC: x86_64-w64-mingw32-gcc
|
||||||
|
|
||||||
|
- name: Upload artifact
|
||||||
- name: Release binaries
|
uses: actions/upload-artifact@v3
|
||||||
uses: https://gitea.com/actions/release-action@main
|
|
||||||
with:
|
with:
|
||||||
files: |-
|
name: swiped-mod-switcher-${{github.ref_name}}-${{github.run_number}}
|
||||||
bin/**
|
path: bin/
|
||||||
api_key: '${{secrets.RELEASE_TOKEN}}'
|
|
||||||
|
# - name: Release binaries
|
||||||
|
# uses: https://gitea.com/actions/release-action@main
|
||||||
|
# with:
|
||||||
|
# files: |-
|
||||||
|
# bin/**
|
||||||
|
# api_key: '${{secrets.RELEASE_TOKEN}}'
|
||||||
|
|||||||
@@ -2,5 +2,3 @@
|
|||||||
Icon = "icon.png"
|
Icon = "icon.png"
|
||||||
Name = "Swiped Mod Switcher"
|
Name = "Swiped Mod Switcher"
|
||||||
ID = "com.s1d3sw1ped.swipedmodswitcher"
|
ID = "com.s1d3sw1ped.swipedmodswitcher"
|
||||||
Version = "0.0.0"
|
|
||||||
Build = 2
|
|
||||||
|
|||||||
38
main.go
38
main.go
@@ -4,9 +4,9 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
"runtime/debug"
|
||||||
"s1d3sw1ped/swipedmodswitcher/admin"
|
"s1d3sw1ped/swipedmodswitcher/admin"
|
||||||
"slices"
|
"slices"
|
||||||
"strconv"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"fyne.io/fyne/v2"
|
"fyne.io/fyne/v2"
|
||||||
@@ -18,8 +18,6 @@ import (
|
|||||||
"gopkg.in/yaml.v3"
|
"gopkg.in/yaml.v3"
|
||||||
)
|
)
|
||||||
|
|
||||||
var Version = ""
|
|
||||||
|
|
||||||
type Config struct {
|
type Config struct {
|
||||||
ModProfilesDirectory string `yaml:"mod_profiles_dir"`
|
ModProfilesDirectory string `yaml:"mod_profiles_dir"`
|
||||||
GameModsDirectory string `yaml:"game_mods_dir"`
|
GameModsDirectory string `yaml:"game_mods_dir"`
|
||||||
@@ -63,16 +61,42 @@ var cfg *Config
|
|||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
if !admin.Admin() {
|
if !admin.Admin() {
|
||||||
|
fmt.Println("not running as administrator relaunching")
|
||||||
if err := admin.RunSelfElevated(); err != nil {
|
if err := admin.RunSelfElevated(); err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
os.Exit(0)
|
os.Exit(0)
|
||||||
|
return // just incase
|
||||||
}
|
}
|
||||||
|
|
||||||
cfg = loadConfig()
|
cfg = loadConfig()
|
||||||
|
|
||||||
ap := app.New()
|
ap := app.New()
|
||||||
wp := ap.NewWindow(ap.Metadata().Name + " v" + ap.Metadata().Version + "." + strconv.Itoa(ap.Metadata().Build))
|
|
||||||
|
commithash := func() string {
|
||||||
|
if info, ok := debug.ReadBuildInfo(); ok {
|
||||||
|
for _, setting := range info.Settings {
|
||||||
|
if setting.Key == "vcs.revision" {
|
||||||
|
return setting.Value
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ""
|
||||||
|
}()
|
||||||
|
|
||||||
|
buildversion := ap.Metadata().Custom["BuildVersion"]
|
||||||
|
if buildversion == "" {
|
||||||
|
buildversion = ""
|
||||||
|
}
|
||||||
|
|
||||||
|
buildnumber := ap.Metadata().Custom["BuildNumber"]
|
||||||
|
if buildnumber == "" {
|
||||||
|
buildnumber = "commit " + commithash
|
||||||
|
} else {
|
||||||
|
buildnumber = "build " + buildnumber
|
||||||
|
}
|
||||||
|
|
||||||
|
wp := ap.NewWindow(ap.Metadata().Name + " " + buildversion + " " + buildnumber)
|
||||||
wp.Resize(fyne.NewSize(600, 1))
|
wp.Resize(fyne.NewSize(600, 1))
|
||||||
wp.CenterOnScreen()
|
wp.CenterOnScreen()
|
||||||
|
|
||||||
@@ -138,10 +162,14 @@ func fillGrid(grid *fyne.Container, parent fyne.Window) {
|
|||||||
grid.Hide()
|
grid.Hide()
|
||||||
defer grid.Show()
|
defer grid.Show()
|
||||||
grid.RemoveAll()
|
grid.RemoveAll()
|
||||||
|
if admin.Admin() {
|
||||||
for _, profile := range profiles {
|
for _, profile := range profiles {
|
||||||
profilename := filepath.Base(profile)
|
profilename := filepath.Base(profile)
|
||||||
grid.Add(widget.NewButton(profilename, makeIFunc(profile, archive, parent)))
|
grid.Add(widget.NewButton(profilename, makeIFunc(profile, archive, parent)))
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
grid.Add(widget.NewLabel("not running as administrator"))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func scanProfiles(profilesroot string) []string {
|
func scanProfiles(profilesroot string) []string {
|
||||||
@@ -183,6 +211,6 @@ func makeIFunc(profile, archive string, parent fyne.Window) func() {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
dialog.NewInformation("Success", fmt.Sprintf("filinked files from %s to %s", filepath.Base(profile), archive), parent).Show()
|
dialog.NewInformation("Success", fmt.Sprintf("linked files from %s to %s", filepath.Base(profile), archive), parent).Show()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user