rebrand to Swiped Mod Switcher and new README
This commit is contained in:
36
main.go
36
main.go
@@ -4,7 +4,7 @@ import (
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"s1d3sw1ped/cpms/admin"
|
||||
"s1d3sw1ped/swipedmodswitcher/admin"
|
||||
"slices"
|
||||
"strings"
|
||||
|
||||
@@ -18,8 +18,8 @@ import (
|
||||
)
|
||||
|
||||
type Config struct {
|
||||
ProfilesRoot string `yaml:"profiles_root"`
|
||||
ArchiveRoot string `yaml:"archive_root"`
|
||||
ModProfilesDirectory string `yaml:"mod_profiles_dir"`
|
||||
GameModsDirectory string `yaml:"game_mods_dir"`
|
||||
}
|
||||
|
||||
func saveConfig(cfg Config) {
|
||||
@@ -38,7 +38,7 @@ func loadConfig() *Config {
|
||||
_, err := os.Stat("config.yaml")
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
saveConfig(Config{ProfilesRoot: "", ArchiveRoot: ""})
|
||||
saveConfig(Config{ModProfilesDirectory: "", GameModsDirectory: ""})
|
||||
}
|
||||
|
||||
d, err := os.ReadFile("config.yaml")
|
||||
@@ -69,7 +69,7 @@ func main() {
|
||||
cfg = loadConfig()
|
||||
|
||||
ap := app.New()
|
||||
wp := ap.NewWindow("Cyberpunk Mod Switcher")
|
||||
wp := ap.NewWindow("Swiped Mod Switcher")
|
||||
wp.Resize(fyne.NewSize(600, 1))
|
||||
wp.CenterOnScreen()
|
||||
|
||||
@@ -81,15 +81,15 @@ func main() {
|
||||
fillGrid(grid, wp)
|
||||
|
||||
profilesrootentry := widget.NewEntry()
|
||||
profilesrootentry.SetText(cfg.ProfilesRoot)
|
||||
profilesrootentry.SetText(cfg.ModProfilesDirectory)
|
||||
profilesrootentry.Disable()
|
||||
|
||||
archiverootentry := widget.NewEntry()
|
||||
archiverootentry.SetText(cfg.ArchiveRoot)
|
||||
archiverootentry.SetText(cfg.GameModsDirectory)
|
||||
archiverootentry.Disable()
|
||||
|
||||
container := container.NewVBox(
|
||||
widget.NewForm(widget.NewFormItem("Profiles Directory", profilesrootentry)),
|
||||
widget.NewForm(widget.NewFormItem("Mod Profiles Directory", profilesrootentry)),
|
||||
widget.NewButtonWithIcon("Select", theme.FolderIcon(), func() {
|
||||
dialog.NewFolderOpen(func(lu fyne.ListableURI, err error) {
|
||||
if err != nil {
|
||||
@@ -99,12 +99,12 @@ func main() {
|
||||
return
|
||||
}
|
||||
profilesrootentry.SetText(lu.Path())
|
||||
cfg.ProfilesRoot = lu.Path()
|
||||
cfg.ModProfilesDirectory = lu.Path()
|
||||
saveConfig(*cfg)
|
||||
fillGrid(grid, wp)
|
||||
}, wp).Show()
|
||||
}),
|
||||
widget.NewForm(widget.NewFormItem("Archive Directory", archiverootentry)),
|
||||
widget.NewForm(widget.NewFormItem("Game Mod Directory", archiverootentry)),
|
||||
widget.NewButtonWithIcon("Select", theme.FolderIcon(), func() {
|
||||
dialog.NewFolderOpen(func(lu fyne.ListableURI, err error) {
|
||||
if err != nil {
|
||||
@@ -114,13 +114,13 @@ func main() {
|
||||
return
|
||||
}
|
||||
archiverootentry.SetText(lu.Path())
|
||||
cfg.ArchiveRoot = lu.Path()
|
||||
cfg.GameModsDirectory = lu.Path()
|
||||
saveConfig(*cfg)
|
||||
fillGrid(grid, wp)
|
||||
}, wp).Show()
|
||||
}),
|
||||
widget.NewSeparator(),
|
||||
widget.NewButton("Reload Profiles", func() {
|
||||
widget.NewButton("Reload Mod Profiles", func() {
|
||||
fillGrid(grid, wp)
|
||||
}),
|
||||
scroll,
|
||||
@@ -130,8 +130,8 @@ func main() {
|
||||
}
|
||||
|
||||
func fillGrid(grid *fyne.Container, parent fyne.Window) {
|
||||
profiles := scanProfiles(cfg.ProfilesRoot)
|
||||
archive := cfg.ArchiveRoot
|
||||
profiles := scanProfiles(cfg.ModProfilesDirectory)
|
||||
archive := cfg.GameModsDirectory
|
||||
grid.Hide()
|
||||
defer grid.Show()
|
||||
grid.RemoveAll()
|
||||
@@ -165,8 +165,8 @@ func scanProfiles(profilesroot string) []string {
|
||||
|
||||
func makeIFunc(profile, archive string, parent fyne.Window) func() {
|
||||
return func() {
|
||||
if cfg.ArchiveRoot == "" || cfg.ProfilesRoot == "" {
|
||||
dialog.NewInformation("Notice", "you must select a archive root and profiles root before", parent).Show()
|
||||
if cfg.GameModsDirectory == "" || cfg.ModProfilesDirectory == "" {
|
||||
dialog.NewInformation("Notice", "you must select a game mod directory and mod profiles directory before", parent).Show()
|
||||
return
|
||||
}
|
||||
|
||||
@@ -176,10 +176,10 @@ func makeIFunc(profile, archive string, parent fyne.Window) func() {
|
||||
// link the profile to the archive
|
||||
err := os.Symlink(profile, archive)
|
||||
if err != nil {
|
||||
dialog.NewInformation("Error", "this program must be ran as administrator to allow linking", parent).Show()
|
||||
dialog.NewInformation("Error", "error linking most likely issue is Swiped Mod Switcher is not running as admin", parent).Show()
|
||||
return
|
||||
}
|
||||
|
||||
dialog.NewInformation("Success", fmt.Sprintf("linked files from %s to %s", filepath.Base(profile), archive), parent).Show()
|
||||
dialog.NewInformation("Success", fmt.Sprintf("filinked files from %s to %s", filepath.Base(profile), archive), parent).Show()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user