-
Notifications
You must be signed in to change notification settings - Fork 82
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Convert install finders tracking to self register
- Loading branch information
1 parent
b474ea4
commit 2ab5bc9
Showing
28 changed files
with
336 additions
and
281 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
//go:build unix | ||
|
||
package common | ||
|
||
import ( | ||
"path/filepath" | ||
"strings" | ||
) | ||
|
||
func WinePathProcessor(winePrefix string) func(string) string { | ||
return func(path string) string { | ||
return filepath.Join(winePrefix, "dosdevices", strings.ToLower(path[0:1])+strings.ReplaceAll(path[1:], "\\", "/")) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,21 @@ | ||
package installfinders | ||
|
||
import ( | ||
"log/slog" | ||
"strings" | ||
|
||
"golang.org/x/exp/maps" | ||
|
||
"github.com/satisfactorymodding/SatisfactoryModManager/backend/installfinders/common" | ||
"github.com/satisfactorymodding/SatisfactoryModManager/backend/installfinders/launchers" | ||
|
||
_ "github.com/satisfactorymodding/SatisfactoryModManager/backend/installfinders/launchers/all" // register all launchers | ||
) | ||
|
||
func FindInstallations() ([]*common.Installation, []error) { | ||
return common.FindAll(launchers.GetInstallFinders()...) | ||
registrations := launchers.GetInstallFinders() | ||
|
||
slog.Debug("finding installations", slog.String("launchers", strings.Join(maps.Keys(registrations), ","))) | ||
|
||
return common.FindAll(maps.Values(registrations)...) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package all | ||
|
||
import ( | ||
_ "github.com/satisfactorymodding/SatisfactoryModManager/backend/installfinders/launchers/crossover" // register crossover | ||
_ "github.com/satisfactorymodding/SatisfactoryModManager/backend/installfinders/launchers/epic" // register epic | ||
_ "github.com/satisfactorymodding/SatisfactoryModManager/backend/installfinders/launchers/heroic" // register heroic | ||
_ "github.com/satisfactorymodding/SatisfactoryModManager/backend/installfinders/launchers/legendary" // register legendary | ||
_ "github.com/satisfactorymodding/SatisfactoryModManager/backend/installfinders/launchers/steam" // register steam | ||
) |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
package crossover |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
22 changes: 22 additions & 0 deletions
22
backend/installfinders/launchers/heroic/heroic_flatpak_linux.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package heroic | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
"path/filepath" | ||
|
||
"github.com/satisfactorymodding/SatisfactoryModManager/backend/installfinders/common" | ||
"github.com/satisfactorymodding/SatisfactoryModManager/backend/installfinders/launchers" | ||
) | ||
|
||
func init() { | ||
launchers.Add("Heroic-flatpak", func() ([]*common.Installation, []error) { | ||
homeDir, err := os.UserHomeDir() | ||
if err != nil { | ||
return nil, []error{fmt.Errorf("failed to get user home dir: %w", err)} | ||
} | ||
flatpakXdgConfigHome := filepath.Join(homeDir, ".var", "app", "com.heroicgameslauncher.hgl", "config") | ||
|
||
return findInstallationsHeroic(false, flatpakXdgConfigHome, "Heroic") | ||
}) | ||
} |
This file was deleted.
Oops, something went wrong.
12 changes: 12 additions & 0 deletions
12
backend/installfinders/launchers/heroic/heroic_native_all.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package heroic | ||
|
||
import ( | ||
"github.com/satisfactorymodding/SatisfactoryModManager/backend/installfinders/common" | ||
"github.com/satisfactorymodding/SatisfactoryModManager/backend/installfinders/launchers" | ||
) | ||
|
||
func init() { | ||
launchers.Add("Heroic", func() ([]*common.Installation, []error) { | ||
return findInstallationsHeroic(false, "", "Heroic") | ||
}) | ||
} |
61 changes: 61 additions & 0 deletions
61
backend/installfinders/launchers/heroic/heroic_snap_linux.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
package heroic | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
"path/filepath" | ||
"strconv" | ||
|
||
"github.com/satisfactorymodding/SatisfactoryModManager/backend/installfinders/common" | ||
"github.com/satisfactorymodding/SatisfactoryModManager/backend/installfinders/launchers" | ||
) | ||
|
||
func init() { | ||
launchers.Add("Heroic-snap", func() ([]*common.Installation, []error) { | ||
snapPath, err := getSnapPath() | ||
if err != nil { | ||
return nil, []error{fmt.Errorf("failed to get snap path: %w", err)} | ||
} | ||
|
||
return findInstallationsHeroic(true, filepath.Join(snapPath, ".config"), "Heroic") | ||
}) | ||
} | ||
|
||
func getSnapPath() (string, error) { | ||
homeDir, err := os.UserHomeDir() | ||
if err != nil { | ||
return "", fmt.Errorf("failed to get user home dir: %w", err) | ||
} | ||
snapAppDir := filepath.Join(homeDir, "snap", "heroic") | ||
var latestSnapRevision int | ||
var latestSnapDirName string | ||
items, err := os.ReadDir(snapAppDir) | ||
if err != nil { | ||
return "", fmt.Errorf("failed to read heroic snap dir: %w", err) | ||
} | ||
for _, item := range items { | ||
if item.IsDir() { | ||
folderName := item.Name() | ||
var revision int | ||
if folderName[0] == 'x' { | ||
revision, err = strconv.Atoi(folderName[1:]) | ||
if err != nil { | ||
continue | ||
} | ||
} else { | ||
revision, err = strconv.Atoi(folderName) | ||
if err != nil { | ||
continue | ||
} | ||
} | ||
if latestSnapDirName == "" || revision > latestSnapRevision { | ||
latestSnapRevision = revision | ||
latestSnapDirName = folderName | ||
} | ||
} | ||
} | ||
if latestSnapDirName == "" { | ||
return "", fmt.Errorf("no heroic snap folders found") | ||
} | ||
return filepath.Join(snapAppDir, latestSnapDirName), nil | ||
} |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.