Compare commits
128 Commits
d179a58c29
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
| c1885f174a | |||
|
|
0650dabb15 | ||
| 42af2d6d25 | |||
| 2dbc72bd39 | |||
| d46a142312 | |||
| caa699c651 | |||
|
|
c5f77582c0 | ||
| 06503ce518 | |||
|
|
f1603dc6fa | ||
| f8932166bb | |||
| ffd41348a0 | |||
|
|
12a9c101f2 | ||
|
|
ff6381575e | ||
|
|
acb4401e37 | ||
| 76d8c1744a | |||
|
|
b2bef77f09 | ||
| 4cbb0666cb | |||
| 83cb34001f | |||
| 1f09482950 | |||
| 1af4d225b5 | |||
| 7863c53280 | |||
|
|
35d888ec62 | ||
|
|
15e317b6fe | ||
| 07f11c7d22 | |||
|
|
7c28081b65 | ||
| d9a75a5e21 | |||
|
|
5da6636dd7 | ||
| b04e653350 | |||
|
|
8469610328 | ||
| 9703682b4a | |||
| e281fbafdb | |||
| be35430727 | |||
| 3667bfae52 | |||
| 8ec9119bc1 | |||
| 4924466a93 | |||
| e37e629630 | |||
| e1db654a48 | |||
| ee19aadac9 | |||
| 17b0d9f72e | |||
| 99a59b47c2 | |||
| 77f83b89f6 | |||
|
|
86d4095444 | ||
|
|
3fd22398d3 | ||
| fcb127ef05 | |||
|
|
4cbadb0f6f | ||
|
|
7ef5780e84 | ||
| 7d37c75d64 | |||
| 31f3df710a | |||
| 709a06ffe6 | |||
|
|
777ed46879 | ||
| 89dedb9870 | |||
| 57d8c1b330 | |||
| 4c1de974f0 | |||
| 452fe85d26 | |||
| 8de631afa2 | |||
|
|
242df40852 | ||
| 2c6a8ac7b0 | |||
| 95caed9b33 | |||
|
|
39d120b6b4 | ||
|
|
66772ad2b5 | ||
| cad13efe95 | |||
|
|
08044c7d46 | ||
|
|
bd2f536c5d | ||
| 738d0727ed | |||
| d10d83dd05 | |||
|
|
9fb92a3367 | ||
|
|
6ba0f1bdea | ||
| 6630747d65 | |||
| aaeaebdb03 | |||
|
|
9595f055dd | ||
|
|
2b224eeee7 | ||
| 875202ceb4 | |||
| 63c5871275 | |||
| 4da5f46fdd | |||
| 60e7e9e506 | |||
| a9624e532a | |||
| f5c621f808 | |||
|
|
8d07f92c26 | ||
|
|
9b44f03a0b | ||
| 32174bfb41 | |||
|
|
5c2951884e | ||
|
|
c0aced282b | ||
| 08baf8e1da | |||
|
|
9104c1148e | ||
|
|
764dfe0e07 | ||
| 2e120d9a77 | |||
| b9379f9d66 | |||
|
|
346ac15bcd | ||
|
|
5b00d477c3 | ||
| 527e04972e | |||
| 64abc18256 | |||
|
|
60d71bd20f | ||
|
|
3fcf6ad181 | ||
| b6f08243db | |||
| 8eb82dd204 | |||
|
|
ff5cba66de | ||
|
|
8b75f3d4a1 | ||
| f7539388f9 | |||
| bc478e4702 | |||
|
|
b3edcc46e6 | ||
|
|
be8256466d | ||
| f1e9961bdd | |||
| e75f77be7f | |||
| a5655abe76 | |||
|
|
5f71a5d9b8 | ||
|
|
9d195c7044 | ||
| 9c80432611 | |||
|
|
296120ef95 | ||
|
|
fb9b3f4ebe | ||
| 62e66751d8 | |||
|
|
1a8ff3cd8b | ||
| 8e2cfc67e3 | |||
| 58bb19b43f | |||
| 5fced26e78 | |||
| c47db7b2d4 | |||
| 932990a27a | |||
| 3379e26597 | |||
| 11ec9a09cb | |||
| fd18f10a9c | |||
| 55087d6940 | |||
| dad6742927 | |||
| 703d31c91d | |||
| cf65351d4e | |||
| 0553968907 | |||
| fb0c743e7f | |||
| a14fd98113 | |||
| ec40f2b695 | |||
|
|
a18e7874d0 |
118
.gitea/workflows/pull-request-ci.yaml
Normal file
118
.gitea/workflows/pull-request-ci.yaml
Normal file
@@ -0,0 +1,118 @@
|
|||||||
|
name: CI
|
||||||
|
on:
|
||||||
|
pull_request:
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
lint:
|
||||||
|
name: Lint
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Setup go
|
||||||
|
uses: actions/setup-go@v5
|
||||||
|
with:
|
||||||
|
go-version-file: 'go.mod'
|
||||||
|
check-latest: 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
|
||||||
|
run: go mod tidy
|
||||||
|
|
||||||
|
- name: Lint
|
||||||
|
uses: golangci/golangci-lint-action@v3
|
||||||
|
with:
|
||||||
|
version: latest
|
||||||
|
|
||||||
|
test:
|
||||||
|
name: Test
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Set up go
|
||||||
|
uses: actions/setup-go@v5
|
||||||
|
with:
|
||||||
|
go-version-file: 'go.mod'
|
||||||
|
check-latest: 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: Get fyne command
|
||||||
|
run: |
|
||||||
|
go install fyne.io/fyne/v2/cmd/fyne@latest
|
||||||
|
|
||||||
|
- name: Get go dependencies
|
||||||
|
run: |
|
||||||
|
go mod tidy
|
||||||
|
|
||||||
|
- name: Test
|
||||||
|
run: go test -race -v -shuffle=on ./...
|
||||||
|
|
||||||
|
build:
|
||||||
|
name: Build
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Set up go
|
||||||
|
uses: actions/setup-go@v5
|
||||||
|
with:
|
||||||
|
go-version-file: 'go.mod'
|
||||||
|
check-latest: 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: Get fyne command
|
||||||
|
run: |
|
||||||
|
go install fyne.io/fyne/v2/cmd/fyne@latest
|
||||||
|
|
||||||
|
- name: Get go dependencies
|
||||||
|
run: |
|
||||||
|
go mod tidy
|
||||||
|
|
||||||
|
- name: Build for linux
|
||||||
|
run: |
|
||||||
|
fyne build --os=${GOOS} --metadata BuildVersion=${VERSION} --metadata BuildNumber=${BUILD} -o bin/swiped-mod-switcher-${VERSION}-${BUILD}-${GOOS}-${GOARCH}
|
||||||
|
env:
|
||||||
|
VERSION: ${{github.ref_name}}
|
||||||
|
BUILD: ${{github.run_number}}
|
||||||
|
GOOS: linux
|
||||||
|
GOARCH: amd64
|
||||||
|
EXE: ""
|
||||||
|
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
|
||||||
|
env:
|
||||||
|
VERSION: ${{github.ref_name}}
|
||||||
|
BUILD: ${{github.run_number}}
|
||||||
|
GOOS: windows
|
||||||
|
GOARCH: amd64
|
||||||
|
EXE: ".exe"
|
||||||
|
CGO_ENABLED: 1
|
||||||
|
CC: x86_64-w64-mingw32-gcc
|
||||||
|
|
||||||
|
- name: Upload artifact
|
||||||
|
uses: actions/upload-artifact@v3
|
||||||
|
with:
|
||||||
|
name: swiped-mod-switcher-${{github.ref_name}}-${{github.run_number}}
|
||||||
|
path: bin/
|
||||||
122
.gitea/workflows/push-ci.yaml
Normal file
122
.gitea/workflows/push-ci.yaml
Normal file
@@ -0,0 +1,122 @@
|
|||||||
|
name: CI
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches: [master, develop]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
lint:
|
||||||
|
name: Lint
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: test log
|
||||||
|
run: env | sort
|
||||||
|
|
||||||
|
- name: Setup go
|
||||||
|
uses: actions/setup-go@v5
|
||||||
|
with:
|
||||||
|
go-version-file: 'go.mod'
|
||||||
|
check-latest: 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
|
||||||
|
run: go mod tidy
|
||||||
|
|
||||||
|
- name: Lint
|
||||||
|
uses: golangci/golangci-lint-action@v3
|
||||||
|
with:
|
||||||
|
version: latest
|
||||||
|
|
||||||
|
test:
|
||||||
|
name: Test
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Set up go
|
||||||
|
uses: actions/setup-go@v5
|
||||||
|
with:
|
||||||
|
go-version-file: 'go.mod'
|
||||||
|
check-latest: 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: Get fyne command
|
||||||
|
run: |
|
||||||
|
go install fyne.io/fyne/v2/cmd/fyne@latest
|
||||||
|
|
||||||
|
- name: Get go dependencies
|
||||||
|
run: |
|
||||||
|
go mod tidy
|
||||||
|
|
||||||
|
- name: Test
|
||||||
|
run: go test -race -v -shuffle=on ./...
|
||||||
|
|
||||||
|
build:
|
||||||
|
name: Build
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Set up go
|
||||||
|
uses: actions/setup-go@v5
|
||||||
|
with:
|
||||||
|
go-version-file: 'go.mod'
|
||||||
|
check-latest: 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: Get fyne command
|
||||||
|
run: |
|
||||||
|
go install fyne.io/fyne/v2/cmd/fyne@latest
|
||||||
|
|
||||||
|
- name: Get go dependencies
|
||||||
|
run: |
|
||||||
|
go mod tidy
|
||||||
|
|
||||||
|
- name: Build for linux
|
||||||
|
run: |
|
||||||
|
fyne build --os=${GOOS} --metadata BuildVersion=${VERSION} --metadata BuildNumber=${BUILD} -o bin/swiped-mod-switcher-${VERSION}-${BUILD}-${GOOS}-${GOARCH}
|
||||||
|
ls bin
|
||||||
|
env:
|
||||||
|
VERSION: ${{github.ref_name}}
|
||||||
|
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
|
||||||
|
uses: actions/upload-artifact@v3
|
||||||
|
with:
|
||||||
|
name: swiped-mod-switcher-${{github.ref_name}}-${{github.run_number}}
|
||||||
|
path: bin/
|
||||||
124
.gitea/workflows/tag-release.yaml
Normal file
124
.gitea/workflows/tag-release.yaml
Normal file
@@ -0,0 +1,124 @@
|
|||||||
|
name: Release versioned tag
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
tags:
|
||||||
|
- 'v*'
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
lint:
|
||||||
|
name: Lint
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Setup go
|
||||||
|
uses: actions/setup-go@v5
|
||||||
|
with:
|
||||||
|
go-version-file: 'go.mod'
|
||||||
|
check-latest: 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
|
||||||
|
run: go mod tidy
|
||||||
|
|
||||||
|
- name: Lint
|
||||||
|
uses: golangci/golangci-lint-action@v3
|
||||||
|
with:
|
||||||
|
version: latest
|
||||||
|
|
||||||
|
test:
|
||||||
|
name: Test
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Set up go
|
||||||
|
uses: actions/setup-go@v5
|
||||||
|
with:
|
||||||
|
go-version-file: 'go.mod'
|
||||||
|
check-latest: 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: Get fyne command
|
||||||
|
run: |
|
||||||
|
go install fyne.io/fyne/v2/cmd/fyne@latest
|
||||||
|
|
||||||
|
- name: Get go dependencies
|
||||||
|
run: |
|
||||||
|
go mod tidy
|
||||||
|
|
||||||
|
- name: Test
|
||||||
|
run: go test -race -v -shuffle=on ./...
|
||||||
|
|
||||||
|
release:
|
||||||
|
name: Build versioned release
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Setup go
|
||||||
|
uses: actions/setup-go@v5
|
||||||
|
with:
|
||||||
|
go-version-file: 'go.mod'
|
||||||
|
|
||||||
|
- name: Setup OS dependencies
|
||||||
|
run: |
|
||||||
|
apt-get update
|
||||||
|
apt-get install -y gcc-mingw-w64 gcc libgl1-mesa-dev xorg-dev
|
||||||
|
|
||||||
|
- name: Install fyne command
|
||||||
|
run: |
|
||||||
|
go install fyne.io/fyne/v2/cmd/fyne@latest
|
||||||
|
|
||||||
|
- name: Install go dependencies
|
||||||
|
run: go mod tidy
|
||||||
|
|
||||||
|
- name: Build for linux
|
||||||
|
run: |
|
||||||
|
fyne build --release --os=${GOOS} --metadata BuildVersion=${VERSION} --metadata BuildNumber=${BUILD} -o bin/swiped-mod-switcher-${VERSION#v}-${BUILD}-${GOOS}-${GOARCH}
|
||||||
|
env:
|
||||||
|
VERSION: ${{github.ref_name}}
|
||||||
|
BUILD: ${{github.run_number}}
|
||||||
|
GOOS: linux
|
||||||
|
GOARCH: amd64
|
||||||
|
EXE: ""
|
||||||
|
CGO_ENABLED: 1
|
||||||
|
CC: gcc
|
||||||
|
|
||||||
|
- name: Build for windows
|
||||||
|
run: |
|
||||||
|
fyne build --release --os=${GOOS} --metadata BuildVersion=${VERSION} --metadata BuildNumber=${BUILD} -o bin/swiped-mod-switcher-${VERSION#v}-${BUILD}-${GOOS}-${GOARCH}.exe
|
||||||
|
env:
|
||||||
|
VERSION: ${{github.ref_name}}
|
||||||
|
BUILD: ${{github.run_number}}
|
||||||
|
GOOS: windows
|
||||||
|
GOARCH: amd64
|
||||||
|
EXE: ".exe"
|
||||||
|
CGO_ENABLED: 1
|
||||||
|
CC: x86_64-w64-mingw32-gcc
|
||||||
|
|
||||||
|
- name: Upload artifact
|
||||||
|
uses: actions/upload-artifact@v3
|
||||||
|
with:
|
||||||
|
name: swiped-mod-switcher-${{github.ref_name}}-${{github.run_number}}
|
||||||
|
path: bin/
|
||||||
|
|
||||||
|
- name: Release binaries
|
||||||
|
uses: https://gitea.com/actions/release-action@main
|
||||||
|
with:
|
||||||
|
files: |-
|
||||||
|
bin/**
|
||||||
|
api_key: '${{secrets.RELEASE_TOKEN}}'
|
||||||
4
.gitignore
vendored
4
.gitignore
vendored
@@ -2,5 +2,9 @@
|
|||||||
bin/
|
bin/
|
||||||
examples/
|
examples/
|
||||||
|
|
||||||
|
fyne_*.go
|
||||||
|
fyne.*
|
||||||
|
|
||||||
cpms.exe
|
cpms.exe
|
||||||
config.yaml
|
config.yaml
|
||||||
|
cpms.7z
|
||||||
|
|||||||
4
FyneApp.toml
Normal file
4
FyneApp.toml
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
[Details]
|
||||||
|
Icon = "icon.png"
|
||||||
|
Name = "Swiped Mod Switcher"
|
||||||
|
ID = "com.s1d3sw1ped.swipedmodswitcher"
|
||||||
35
README.md
Normal file
35
README.md
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
# Swiped Mod Switcher
|
||||||
|
A simple but effective mod switcher for simple game such as Sims.
|
||||||
|
|
||||||
|
it works by switching out a games mod folder with one of the ones made by you and placed under the profiles directory.
|
||||||
|
|
||||||
|
the switch is really just a symbolic link so it happens in milliseconds even on slow hard drives regardless of the amount or size of mods in the folder.
|
||||||
|
|
||||||
|
### Upsides
|
||||||
|
- it is very very fast even switching a folder with 100+GB on a slow slow hdd in a few milliseconds.
|
||||||
|
- makes having a normal and lewd version of your mods easy to switch between.
|
||||||
|
- makes having a different set of mods depending on who your playing with easier aswell.
|
||||||
|
|
||||||
|
### Downsides
|
||||||
|
- it does not manage mods you manage them yourself and place them in the profiles directory.
|
||||||
|
- it does not deduplicate your mods if you have mods 'A' installed in 2 profiles it will take size of 'A' x2 room on your hdd.
|
||||||
|
- because it switches your games mods folder it does work with existing mod managers mostly however they may get slow having to figure out what mods are installed already when they open or may even get borked if they keep an external journal of what is installed.
|
||||||
|
|
||||||
|
### Never Happening
|
||||||
|
- deduplicating mods will never be supported that's a pile of crazy I don't want to touch.
|
||||||
|
|
||||||
|
## Installation
|
||||||
|
1. Download the latest version from the releases page. https://git.s1d3sw1ped.com/s1d3sw1ped/SwipedModSwitcher/releases
|
||||||
|
2. Make a folder and place it in there.
|
||||||
|
3. Make a second folder in that folder named profiles.
|
||||||
|
4. Open Swiped Mod Switcher and select the second folder in the Mod Profiles Directory selection.
|
||||||
|
5. Then select your games current mod folder in the Game Mods Directory selection.
|
||||||
|
6. Now if you already have some mods installed make a new folder in the Mod Profiles Directory name it whatever you would like to call the profile and then copy the current mods to that folder once done you can delete the games mod folder dont worry Swiped Mod Switcher will remake the folder itself when you select a profile.
|
||||||
|
7. Click Reload Mod Profiles and it should display your profile then simply click it to switch to that profile.
|
||||||
|
8. Play your game or create more profiles the choice at this point is yours.
|
||||||
|
|
||||||
|
## Disclaimer
|
||||||
|
No testing goes into ensuring the linux builds actually work.
|
||||||
|
|
||||||
|
## Virus Warning
|
||||||
|
There are alot of false positives with golang programs if you got a warning for this app it was 99% a false positive however if you believe that it may not be a false positive then either check with virustotal or delete it. there is basically nothing i can do to make your virus scanner not think its a virus and im not spending the years to call or email your virus scanner company to have them fix it. if it really bothers you then do that yourself.
|
||||||
13
admin/admin_linux.go
Normal file
13
admin/admin_linux.go
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
package admin
|
||||||
|
|
||||||
|
import "errors"
|
||||||
|
|
||||||
|
var ErrNotImplemented = errors.New("not implemented on linux")
|
||||||
|
|
||||||
|
func RunSelfElevated() error {
|
||||||
|
return ErrNotImplemented
|
||||||
|
}
|
||||||
|
|
||||||
|
func Admin() bool {
|
||||||
|
return true
|
||||||
|
}
|
||||||
41
admin/admin_windows.go
Normal file
41
admin/admin_windows.go
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
package admin
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
"strings"
|
||||||
|
"syscall"
|
||||||
|
|
||||||
|
"golang.org/x/sys/windows"
|
||||||
|
)
|
||||||
|
|
||||||
|
func RunSelfElevated() error {
|
||||||
|
verb := "runas"
|
||||||
|
exe, _ := os.Executable()
|
||||||
|
cwd, _ := os.Getwd()
|
||||||
|
args := strings.Join(os.Args[1:], " ")
|
||||||
|
|
||||||
|
verbPtr, _ := syscall.UTF16PtrFromString(verb)
|
||||||
|
exePtr, _ := syscall.UTF16PtrFromString(exe)
|
||||||
|
cwdPtr, _ := syscall.UTF16PtrFromString(cwd)
|
||||||
|
argPtr, _ := syscall.UTF16PtrFromString(args)
|
||||||
|
|
||||||
|
var showCmd int32 = 1 //SW_NORMAL
|
||||||
|
|
||||||
|
err := windows.ShellExecute(0, verbPtr, exePtr, argPtr, cwdPtr, showCmd)
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func Admin() bool {
|
||||||
|
_, err := os.Open("\\\\.\\PHYSICALDRIVE0")
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println("admin no")
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
fmt.Println("admin yes")
|
||||||
|
return true
|
||||||
|
}
|
||||||
@@ -1,2 +0,0 @@
|
|||||||
profiles_root: E:/GoWork/cpms/examples/profiles
|
|
||||||
archive_root: E:/GoWork/cpms/examples/archive
|
|
||||||
7
go.mod
7
go.mod
@@ -1,10 +1,10 @@
|
|||||||
module s1d3sw1ped/cpms
|
module s1d3sw1ped/swipedmodswitcher
|
||||||
|
|
||||||
go 1.20
|
go 1.22
|
||||||
|
|
||||||
require (
|
require (
|
||||||
fyne.io/fyne/v2 v2.3.5
|
fyne.io/fyne/v2 v2.3.5
|
||||||
github.com/otiai10/copy v1.12.0
|
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f
|
||||||
gopkg.in/yaml.v3 v3.0.1
|
gopkg.in/yaml.v3 v3.0.1
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -32,7 +32,6 @@ require (
|
|||||||
golang.org/x/image v0.3.0 // indirect
|
golang.org/x/image v0.3.0 // indirect
|
||||||
golang.org/x/mobile v0.0.0-20211207041440-4e6c2922fdee // indirect
|
golang.org/x/mobile v0.0.0-20211207041440-4e6c2922fdee // indirect
|
||||||
golang.org/x/net v0.0.0-20220722155237-a158d28d115b // indirect
|
golang.org/x/net v0.0.0-20220722155237-a158d28d115b // indirect
|
||||||
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f // indirect
|
|
||||||
golang.org/x/text v0.6.0 // indirect
|
golang.org/x/text v0.6.0 // indirect
|
||||||
honnef.co/go/js/dom v0.0.0-20210725211120-f030747120f2 // indirect
|
honnef.co/go/js/dom v0.0.0-20210725211120-f030747120f2 // indirect
|
||||||
)
|
)
|
||||||
|
|||||||
3
go.sum
3
go.sum
@@ -234,9 +234,6 @@ github.com/neelance/sourcemap v0.0.0-20200213170602-2833bce08e4c/go.mod h1:Qr6/a
|
|||||||
github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646/go.mod h1:jpp1/29i3P1S/RLdc7JQKbRpFeM1dOBd8T9ki5s+AY8=
|
github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646/go.mod h1:jpp1/29i3P1S/RLdc7JQKbRpFeM1dOBd8T9ki5s+AY8=
|
||||||
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e h1:fD57ERR4JtEqsWbfPhv4DMiApHyliiK5xCTNVSPiaAs=
|
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e h1:fD57ERR4JtEqsWbfPhv4DMiApHyliiK5xCTNVSPiaAs=
|
||||||
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno=
|
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno=
|
||||||
github.com/otiai10/copy v1.12.0 h1:cLMgSQnXBs1eehF0Wy/FAGsgDTDmAqFR7rQylBb1nDY=
|
|
||||||
github.com/otiai10/copy v1.12.0/go.mod h1:rSaLseMUsZFFbsFGc7wCJnnkTAvdc5L6VWxPE4308Ww=
|
|
||||||
github.com/otiai10/mint v1.5.1 h1:XaPLeE+9vGbuyEHem1JNk3bYc7KKqyI/na0/mLd/Kks=
|
|
||||||
github.com/pascaldekloe/goe v0.0.0-20180627143212-57f6aae5913c/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc=
|
github.com/pascaldekloe/goe v0.0.0-20180627143212-57f6aae5913c/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc=
|
||||||
github.com/pelletier/go-toml v1.9.3/go.mod h1:u1nR/EPcESfeI/szUZKdtJ0xRNbUoANCkoOuaOx1Y+c=
|
github.com/pelletier/go-toml v1.9.3/go.mod h1:u1nR/EPcESfeI/szUZKdtJ0xRNbUoANCkoOuaOx1Y+c=
|
||||||
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 3.3 KiB After Width: | Height: | Size: 3.3 KiB |
143
main.go
143
main.go
@@ -2,9 +2,11 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/fs"
|
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
"runtime/debug"
|
||||||
|
"s1d3sw1ped/swipedmodswitcher/admin"
|
||||||
|
"slices"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"fyne.io/fyne/v2"
|
"fyne.io/fyne/v2"
|
||||||
@@ -14,13 +16,11 @@ import (
|
|||||||
"fyne.io/fyne/v2/theme"
|
"fyne.io/fyne/v2/theme"
|
||||||
"fyne.io/fyne/v2/widget"
|
"fyne.io/fyne/v2/widget"
|
||||||
"gopkg.in/yaml.v3"
|
"gopkg.in/yaml.v3"
|
||||||
|
|
||||||
cp "github.com/otiai10/copy"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type Config struct {
|
type Config struct {
|
||||||
ProfilesRoot string `yaml:"profiles_root"`
|
ModProfilesDirectory string `yaml:"mod_profiles_dir"`
|
||||||
ArchiveRoot string `yaml:"archive_root"`
|
GameModsDirectory string `yaml:"game_mods_dir"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func saveConfig(cfg Config) {
|
func saveConfig(cfg Config) {
|
||||||
@@ -39,7 +39,7 @@ func loadConfig() *Config {
|
|||||||
_, err := os.Stat("config.yaml")
|
_, err := os.Stat("config.yaml")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println(err)
|
fmt.Println(err)
|
||||||
saveConfig(Config{ProfilesRoot: "", ArchiveRoot: ""})
|
saveConfig(Config{ModProfilesDirectory: "", GameModsDirectory: ""})
|
||||||
}
|
}
|
||||||
|
|
||||||
d, err := os.ReadFile("config.yaml")
|
d, err := os.ReadFile("config.yaml")
|
||||||
@@ -57,31 +57,66 @@ func loadConfig() *Config {
|
|||||||
return &cfg
|
return &cfg
|
||||||
}
|
}
|
||||||
|
|
||||||
var cfg = loadConfig()
|
var cfg *Config
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
if !admin.Admin() {
|
||||||
|
fmt.Println("not running as administrator relaunching")
|
||||||
|
if err := admin.RunSelfElevated(); err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
os.Exit(0)
|
||||||
|
return // just incase
|
||||||
|
}
|
||||||
|
|
||||||
|
cfg = loadConfig()
|
||||||
|
|
||||||
ap := app.New()
|
ap := app.New()
|
||||||
wp := ap.NewWindow("Cyberpunk Mod Switcher")
|
|
||||||
wp.Resize(fyne.NewSize(1024, 768))
|
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.CenterOnScreen()
|
wp.CenterOnScreen()
|
||||||
|
|
||||||
grid := container.NewVBox()
|
grid := container.NewVBox()
|
||||||
scroll := container.NewVScroll(grid)
|
scroll := container.NewVScroll(grid)
|
||||||
scroll.SetMinSize(fyne.NewSize(-1, 768))
|
scroll.SetMinSize(fyne.NewSize(-1, 400))
|
||||||
|
|
||||||
//load grid
|
//load grid
|
||||||
fillGrid(grid, wp)
|
fillGrid(grid, wp)
|
||||||
|
|
||||||
profilesrootentry := widget.NewEntry()
|
profilesrootentry := widget.NewEntry()
|
||||||
profilesrootentry.SetText(cfg.ProfilesRoot)
|
profilesrootentry.SetText(cfg.ModProfilesDirectory)
|
||||||
profilesrootentry.Disable()
|
profilesrootentry.Disable()
|
||||||
|
|
||||||
archiverootentry := widget.NewEntry()
|
archiverootentry := widget.NewEntry()
|
||||||
archiverootentry.SetText(cfg.ArchiveRoot)
|
archiverootentry.SetText(cfg.GameModsDirectory)
|
||||||
archiverootentry.Disable()
|
archiverootentry.Disable()
|
||||||
|
|
||||||
container := container.NewVBox(
|
container := container.NewVBox(
|
||||||
widget.NewForm(widget.NewFormItem("Profiles Directory", profilesrootentry)),
|
widget.NewForm(widget.NewFormItem("Mod Profiles Directory", profilesrootentry)),
|
||||||
widget.NewButtonWithIcon("Select", theme.FolderIcon(), func() {
|
widget.NewButtonWithIcon("Select", theme.FolderIcon(), func() {
|
||||||
dialog.NewFolderOpen(func(lu fyne.ListableURI, err error) {
|
dialog.NewFolderOpen(func(lu fyne.ListableURI, err error) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -91,12 +126,12 @@ func main() {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
profilesrootentry.SetText(lu.Path())
|
profilesrootentry.SetText(lu.Path())
|
||||||
cfg.ProfilesRoot = lu.Path()
|
cfg.ModProfilesDirectory = lu.Path()
|
||||||
saveConfig(*cfg)
|
saveConfig(*cfg)
|
||||||
fillGrid(grid, wp)
|
fillGrid(grid, wp)
|
||||||
}, wp).Show()
|
}, wp).Show()
|
||||||
}),
|
}),
|
||||||
widget.NewForm(widget.NewFormItem("Archive Directory", archiverootentry)),
|
widget.NewForm(widget.NewFormItem("Game Mod Directory", archiverootentry)),
|
||||||
widget.NewButtonWithIcon("Select", theme.FolderIcon(), func() {
|
widget.NewButtonWithIcon("Select", theme.FolderIcon(), func() {
|
||||||
dialog.NewFolderOpen(func(lu fyne.ListableURI, err error) {
|
dialog.NewFolderOpen(func(lu fyne.ListableURI, err error) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -106,13 +141,13 @@ func main() {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
archiverootentry.SetText(lu.Path())
|
archiverootentry.SetText(lu.Path())
|
||||||
cfg.ArchiveRoot = lu.Path()
|
cfg.GameModsDirectory = lu.Path()
|
||||||
saveConfig(*cfg)
|
saveConfig(*cfg)
|
||||||
fillGrid(grid, wp)
|
fillGrid(grid, wp)
|
||||||
}, wp).Show()
|
}, wp).Show()
|
||||||
}),
|
}),
|
||||||
widget.NewSeparator(),
|
widget.NewSeparator(),
|
||||||
widget.NewButton("Reload Profiles", func() {
|
widget.NewButton("Reload Mod Profiles", func() {
|
||||||
fillGrid(grid, wp)
|
fillGrid(grid, wp)
|
||||||
}),
|
}),
|
||||||
scroll,
|
scroll,
|
||||||
@@ -122,72 +157,60 @@ func main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func fillGrid(grid *fyne.Container, parent fyne.Window) {
|
func fillGrid(grid *fyne.Container, parent fyne.Window) {
|
||||||
profiles := scanProfiles(cfg.ProfilesRoot)
|
profiles := scanProfiles(cfg.ModProfilesDirectory)
|
||||||
archive := cfg.ArchiveRoot
|
archive := cfg.GameModsDirectory
|
||||||
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 := strings.TrimSuffix(filepath.Base(profile), ".cpms")
|
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 {
|
||||||
dir := filepath.Join(profilesroot, "*.cpms/")
|
dir := filepath.Join(profilesroot, "*/")
|
||||||
m, err := filepath.Glob(dir)
|
m, err := filepath.Glob(dir)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println(err)
|
fmt.Println(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
return m
|
mm := []string{}
|
||||||
|
|
||||||
|
for _, path := range m {
|
||||||
|
if s, err := os.Stat(path); err == nil && !strings.HasPrefix(s.Name(), ".") && s.IsDir() {
|
||||||
|
mm = append(mm, path)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
slices.SortStableFunc(mm, func(a, b string) int {
|
||||||
|
return strings.Compare(a, b)
|
||||||
|
})
|
||||||
|
|
||||||
|
return mm
|
||||||
}
|
}
|
||||||
|
|
||||||
func makeIFunc(profile, archive string, parent fyne.Window) func() {
|
func makeIFunc(profile, archive string, parent fyne.Window) func() {
|
||||||
return func() {
|
return func() {
|
||||||
if cfg.ArchiveRoot == "" || cfg.ProfilesRoot == "" {
|
if cfg.GameModsDirectory == "" || cfg.ModProfilesDirectory == "" {
|
||||||
d := dialog.NewInformation("Notice", "you must select a archive root and profiles root before", parent)
|
dialog.NewInformation("Notice", "you must select a game mod directory and mod profiles directory before", parent).Show()
|
||||||
d.Show()
|
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
dialog.NewConfirm("Are You Sure?", fmt.Sprintf("the current contents of %s will be lost", archive), func(b bool) {
|
// delete any existing archive folder
|
||||||
if b {
|
_ = os.RemoveAll(archive)
|
||||||
err := walk(archive, func(path string, info fs.FileInfo, err error) error {
|
|
||||||
|
// link the profile to the archive
|
||||||
|
err := os.Symlink(profile, archive)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
dialog.NewInformation("Error", "error linking most likely issue is Swiped Mod Switcher is not running as admin", parent).Show()
|
||||||
}
|
return
|
||||||
err = os.Remove(path)
|
|
||||||
if err != nil {
|
|
||||||
fmt.Println(err)
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
})
|
|
||||||
if err != nil {
|
|
||||||
fmt.Println(err)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
err = cp.Copy(profile, archive)
|
dialog.NewInformation("Success", fmt.Sprintf("linked files from %s to %s", filepath.Base(profile), archive), parent).Show()
|
||||||
if err != nil {
|
|
||||||
fmt.Println(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
dialog.NewInformation("Success", fmt.Sprintf("copied all files from %s to %s", filepath.Base(profile), archive), parent).Show()
|
|
||||||
}
|
|
||||||
}, parent).Show()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func walk(root string, fn filepath.WalkFunc) error {
|
|
||||||
initial := false
|
|
||||||
|
|
||||||
return filepath.Walk(root, func(path string, info fs.FileInfo, err error) error {
|
|
||||||
if !initial {
|
|
||||||
initial = true
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
return fn(path, info, err)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|||||||
Reference in New Issue
Block a user