Skip to content

Commit

Permalink
LaunchBox support for Windows (#110)
Browse files Browse the repository at this point in the history
* Add AutoIt to generic launchers list

* Refactor scanner to include systemId parameter, add LaunchBox launching on Windows

* Remove app name from windows config setup

* Refactor scanner logic and add LaunchBox XML support

* Fix scan bug

* Initial launchbox system map

* Search for launchbox

* Fix lb path bug
  • Loading branch information
wizzomafizzo authored Nov 2, 2024
1 parent 3c68d6f commit 88f19a2
Show file tree
Hide file tree
Showing 4 changed files with 345 additions and 7 deletions.
43 changes: 39 additions & 4 deletions pkg/database/gamesdb/gamesdb.go
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,8 @@ func NewNamesIndex(
// custom scan function if one exists
for _, l := range platform.Launchers() {
if l.SystemId == k && l.Scanner != nil {
files, err = l.Scanner(cfg, files)
log.Debug().Msgf("running %s scanner for system: %s", l.Id, systemId)
files, err = l.Scanner(cfg, systemId, files)
if err != nil {
return status.Files, err
}
Expand Down Expand Up @@ -283,13 +284,13 @@ func NewNamesIndex(
for _, l := range platform.Launchers() {
systemId := l.SystemId
if !scanned[systemId] && l.Scanner != nil {
results, err := l.Scanner(cfg, []platforms.ScanResult{})
log.Debug().Msgf("running %s scanner for system: %s", l.Id, systemId)
results, err := l.Scanner(cfg, systemId, []platforms.ScanResult{})
if err != nil {
return status.Files, err
}

log.Debug().Msgf("scanned %d files for system: %s", len(results), systemId)
log.Debug().Msgf("files: %v", results)

status.Files += len(results)
scanned[systemId] = true
Expand All @@ -301,7 +302,41 @@ func NewNamesIndex(
fis = append(fis, fileInfo{SystemId: systemId, Path: p.Path, Name: p.Name})
}
log.Debug().Msgf("updating names for system: %s", systemId)
log.Debug().Msgf("files: %v", fis)
return updateNames(db, fis)
})
}
}
}

// launcher scanners with no system defined are run against every system
var anyScanners []platforms.Launcher
for _, l := range platform.Launchers() {
if l.SystemId == "" && l.Scanner != nil {
anyScanners = append(anyScanners, l)
}
}

for _, l := range anyScanners {
for _, s := range systems {
log.Debug().Msgf("running %s scanner for system: %s", l.Id, s.Id)
results, err := l.Scanner(cfg, s.Id, []platforms.ScanResult{})
if err != nil {
return status.Files, err
}

log.Debug().Msgf("scanned %d files for system: %s", len(results), s.Id)

if len(results) > 0 {
status.Files += len(results)
scanned[s.Id] = true

systemId := s.Id
g.Go(func() error {
fis := make([]fileInfo, 0)
for _, p := range results {
fis = append(fis, fileInfo{SystemId: systemId, Path: p.Path, Name: p.Name})
}
log.Debug().Msgf("updating names for system: %s", systemId)
return updateNames(db, fis)
})
}
Expand Down
2 changes: 2 additions & 0 deletions pkg/platforms/mister/platform.go
Original file line number Diff line number Diff line change
Expand Up @@ -425,6 +425,7 @@ func (p *Platform) Launchers() []platforms.Launcher {
Launch: launch,
Scanner: func(
cfg *config.UserConfig,
systemId string,
results []platforms.ScanResult,
) ([]platforms.ScanResult, error) {
log.Info().Msg("starting amigavision scan")
Expand Down Expand Up @@ -481,6 +482,7 @@ func (p *Platform) Launchers() []platforms.Launcher {
Launch: launch,
Scanner: func(
cfg *config.UserConfig,
systemId string,
results []platforms.ScanResult,
) ([]platforms.ScanResult, error) {
log.Info().Msg("starting neogeo scan")
Expand Down
2 changes: 1 addition & 1 deletion pkg/platforms/platforms.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ type Launcher struct {
Launch func(*config.UserConfig, string) error
// Optional function to perform custom media scanning. Takes the list of
// results from the standard scan, if any, and returns the final list.
Scanner func(*config.UserConfig, []ScanResult) ([]ScanResult, error)
Scanner func(*config.UserConfig, string, []ScanResult) ([]ScanResult, error)
// If true, all resolved paths must be in the allow list before they
// can be launched.
AllowListOnly bool
Expand Down
Loading

0 comments on commit 88f19a2

Please sign in to comment.