Skip to content

Commit

Permalink
Add .pbp support to ludo (#524)
Browse files Browse the repository at this point in the history
* Basic functionality within ludo

* cleaned up the pbp file check

* cleaned up trailing whitespace

* Added m3u support and improved multi disc playlist support.

* configurable starting path added.

* Updating CI/CD for manual builds.

* attempting to fix the winpthread import.

* I /looks/ like the chocolatey build of mingw64 is broken. This should grab it directly.

* updated cd.yml as well.

* updated actions/checkout and actions/setup-go to current version to quiet CI warnings.

* correcting default starting directory. Should be users home directory.

---------

Co-authored-by: Stephen Ancona <stephen@bagelbyheart.com>
  • Loading branch information
bagelbyheart and Stephen Ancona authored Feb 26, 2024
1 parent 85dfd86 commit ad635fb
Show file tree
Hide file tree
Showing 10 changed files with 59 additions and 37 deletions.
31 changes: 18 additions & 13 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
name: CD

on:
workflow_dispatch:
types: [created]
release:
types: [created]

Expand All @@ -12,10 +14,10 @@ jobs:
build_linux_wayland_x86_64:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
with:
submodules: true
- uses: actions/setup-go@v3
- uses: actions/setup-go@v4
with:
go-version: '1.19.5'
- run: echo "VERSION=$(echo ${{ github.event.release.tag_name }} | cut -c 2-)" >> $GITHUB_ENV
Expand All @@ -36,10 +38,10 @@ jobs:
build_linux_wayland_arm:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
with:
submodules: true
- uses: actions/setup-go@v3
- uses: actions/setup-go@v4
with:
go-version: '1.19.5'
- run: echo "VERSION=$(echo ${{ github.event.release.tag_name }} | cut -c 2-)" >> $GITHUB_ENV
Expand Down Expand Up @@ -72,10 +74,10 @@ jobs:
build_linux_x11_x86_64:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
with:
submodules: true
- uses: actions/setup-go@v3
- uses: actions/setup-go@v4
with:
go-version: '1.19.5'
- run: echo "VERSION=$(echo ${{ github.event.release.tag_name }} | cut -c 2-)" >> $GITHUB_ENV
Expand All @@ -96,10 +98,10 @@ jobs:
build_linux_x11_arm:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
with:
submodules: true
- uses: actions/setup-go@v3
- uses: actions/setup-go@v4
with:
go-version: '1.19.5'
- run: echo "VERSION=$(echo ${{ github.event.release.tag_name }} | cut -c 2-)" >> $GITHUB_ENV
Expand Down Expand Up @@ -132,10 +134,10 @@ jobs:
build_osx:
runs-on: macos-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
with:
submodules: true
- uses: actions/setup-go@v3
- uses: actions/setup-go@v4
with:
go-version: '1.19.5'
- run: echo "VERSION=$(echo ${{ github.event.release.tag_name }} | cut -c 2-)" >> $GITHUB_ENV
Expand Down Expand Up @@ -166,22 +168,25 @@ jobs:
build_windows:
runs-on: windows-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
with:
submodules: true
- uses: actions/setup-go@v3
- uses: actions/setup-go@v4
with:
go-version: '1.19.5'
- run: echo "VERSION=$(echo ${{ github.event.release.tag_name }} | cut -c 2-)" >> $GITHUB_ENV
- run: choco install wget make hashdeep --ignore-checksums
- run: wget --no-check-certificate http://www.openal-soft.org/openal-binaries/openal-soft-1.21.0-bin.zip
- run: wget https://github.com/electron/rcedit/releases/download/v1.1.1/rcedit-x64.exe
- run: curl -L -o mingw64.zip https://github.com/brechtsanders/winlibs_mingw/releases/download/13.2.0posix-17.0.6-11.0.1-ucrt-r5/winlibs-x86_64-posix-seh-gcc-13.2.0-llvm-17.0.6-mingw-w64ucrt-11.0.1-r5.zip
- run: unzip mingw64.zip
- run: 7z x openal-soft-1.21.0-bin.zip -o/c/
- run: echo "CGO_CFLAGS=-I/c/openal-soft-1.21.0-bin/include/" >> $GITHUB_ENV
- run: echo "CGO_LDFLAGS=-L/c/openal-soft-1.21.0-bin/libs/Win64/" >> $GITHUB_ENV
- run: cp /c/ProgramData/chocolatey/lib/mingw/tools/install/mingw64/bin/libwinpthread-1.dll .
- run: cp "mingw64/bin/libwinpthread-1.dll" .
- run: cp /c/openal-soft-1.21.0-bin/bin/Win64/soft_oal.dll OpenAL32.dll
- run: cp /c/Windows/System32/VCRUNTIME140.dll .
- run: PATH="/c/mingw64/bin:$PATH"
- run: mkdir -p ./Ludo-Windows-x86_64-${VERSION}/
- run: cp *.dll ./Ludo-Windows-x86_64-${VERSION}/
- run: OS=Windows ARCH=x86_64 VERSION=$VERSION make zip
Expand Down
31 changes: 18 additions & 13 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
name: CI

on:
workflow_dispatch:
branches: [master]
push:
branches: [master]
pull_request:
Expand All @@ -14,10 +16,10 @@ jobs:
build_linux_wayland_x86_64:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
with:
submodules: true
- uses: actions/setup-go@v3
- uses: actions/setup-go@v4
with:
go-version: '1.19.5'
- run: echo "/home/runner/go/bin" >> $GITHUB_PATH
Expand All @@ -33,10 +35,10 @@ jobs:
build_linux_wayland_arm:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
with:
submodules: true
- uses: actions/setup-go@v3
- uses: actions/setup-go@v4
with:
go-version: '1.19.5'
- run: sudo apt update -q
Expand All @@ -58,10 +60,10 @@ jobs:
build_linux_x11_x86_64:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
with:
submodules: true
- uses: actions/setup-go@v3
- uses: actions/setup-go@v4
with:
go-version: '1.19.5'
- run: echo "/home/runner/go/bin" >> $GITHUB_PATH
Expand All @@ -77,10 +79,10 @@ jobs:
build_linux_x11_arm:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
with:
submodules: true
- uses: actions/setup-go@v3
- uses: actions/setup-go@v4
with:
go-version: '1.19.5'
- run: sudo apt update -q
Expand All @@ -102,10 +104,10 @@ jobs:
build_osx:
runs-on: macos-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
with:
submodules: true
- uses: actions/setup-go@v3
- uses: actions/setup-go@v4
with:
go-version: '1.19.5'
- run: echo "/Users/runner/go/bin" >> $GITHUB_PATH
Expand All @@ -120,20 +122,23 @@ jobs:
build_windows:
runs-on: windows-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
with:
submodules: true
- uses: actions/setup-go@v3
- uses: actions/setup-go@v4
with:
go-version: '1.19.5'
- run: echo "/c/Users/runneradmin/go/bin" >> $GITHUB_PATH
- run: go install honnef.co/go/tools/cmd/staticcheck@latest
- run: choco install wget --ignore-checksums
- run: curl -L -o mingw64.zip https://github.com/brechtsanders/winlibs_mingw/releases/download/13.2.0posix-17.0.6-11.0.1-ucrt-r5/winlibs-x86_64-posix-seh-gcc-13.2.0-llvm-17.0.6-mingw-w64ucrt-11.0.1-r5.zip
- run: unzip mingw64.zip
- run: wget --no-check-certificate http://www.openal-soft.org/openal-binaries/openal-soft-1.21.0-bin.zip
- run: 7z x openal-soft-1.21.0-bin.zip -o/c/
- run: echo "CGO_CFLAGS=-I/c/openal-soft-1.21.0-bin/include/" >> $GITHUB_ENV
- run: echo "CGO_LDFLAGS=-L/c/openal-soft-1.21.0-bin/libs/Win64/" >> $GITHUB_ENV
- run: cp /c/ProgramData/chocolatey/lib/mingw/tools/install/mingw64/bin/libwinpthread-1.dll .
- run: cp "mingw64/bin/libwinpthread-1.dll" .
- run: PATH="/c/mingw64/bin:$PATH"
- run: go get .
#- run: go test -v -race ./...
#- run: go vet ./...
Expand Down
1 change: 1 addition & 0 deletions core/core.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ func unarchiveGame(filename string) (string, int64, error) {
extPrefered := make(map[string]int)
extPrefered[".cue"] = 1
extPrefered[".m3u"] = 2
extPrefered[".pbp"] = 3

err = archiver.Walk(filename, func(f archiver.File) error {
fname := f.Name()
Expand Down
11 changes: 7 additions & 4 deletions dat/dat.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,13 @@ func (db *DB) FindByROMName(romPath string, romName string, crc uint32, games ch
continue
}
// If the checksums match
if romName == game.ROMs[0].Name {
game.Path = romPath
game.System = system
games <- game
for _, ROM := range game.ROMs {
if romName == ROM.Name {
game.Path = romPath
game.System = system
games <- game
}
// element is the element from someSlice for where we are
}
}
wg.Done()
Expand Down
2 changes: 1 addition & 1 deletion database
5 changes: 5 additions & 0 deletions menu/scene_playlist.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ func buildPlaylist(path string) Scene {
for _, game := range playlists.Playlists[path] {
game := game // needed for callbackOK
strippedName, tags := extractTags(game.Name)
if strings.Contains(game.Name, "Disc") {
re := regexp.MustCompile(`\((Disc [1-9]?)\)`)
match := re.FindStringSubmatch(game.Name)
strippedName = strippedName + " (" + match[1] + ")"
}
list.children = append(list.children, entry{
label: strippedName,
gameName: game.Name,
Expand Down
7 changes: 4 additions & 3 deletions menu/scene_tabs.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package menu
import (
"fmt"
"os"
"os/user"
//"os/user"
"sort"

"github.com/libretro/ludo/audio"
Expand All @@ -15,6 +15,7 @@ import (
"github.com/libretro/ludo/state"
"github.com/libretro/ludo/utils"
"github.com/libretro/ludo/video"
"github.com/libretro/ludo/settings"
colorful "github.com/lucasb-eyer/go-colorful"

"github.com/tanema/gween"
Expand Down Expand Up @@ -63,8 +64,8 @@ func buildTabs() Scene {
subLabel: "Scan your collection",
icon: "add",
callbackOK: func() {
usr, _ := user.Current()
menu.Push(buildExplorer(usr.HomeDir, nil,
//usr, _ := user.Current()
menu.Push(buildExplorer(settings.Current.FileDirectory, nil,
func(path string) {
scanner.ScanDir(path, refreshTabs)
},
Expand Down
3 changes: 1 addition & 2 deletions scanner/scanner.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import (
"path/filepath"
"strconv"
"strings"

"github.com/libretro/ludo/dat"
ntf "github.com/libretro/ludo/notifications"
"github.com/libretro/ludo/playlists"
Expand Down Expand Up @@ -131,7 +130,7 @@ func Scan(dir string, roms []string, games chan (dat.Game), n *ntf.Notification)
}
}
z.Close()
case ".cue":
case ".cue", ".pbp", ".m3u":
// Look for a matching game entry in the database
state.DB.FindByROMName(f, filepath.Base(f), 0, games)
n.Update(ntf.Info, strconv.Itoa(i)+"/"+strconv.Itoa(len(roms))+" "+f)
Expand Down
4 changes: 3 additions & 1 deletion settings/defaults.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@ package settings

import (
"path/filepath"

"os/user"
"github.com/adrg/xdg"
)

func defaultSettings() Settings {
usr, _ := user.Current()
return Settings{
VideoFullscreen: false,
VideoMonitorIndex: 0,
Expand Down Expand Up @@ -58,6 +59,7 @@ func defaultSettings() Settings {
"SNK - Neo Geo Pocket": "mednafen_ngp_libretro",
"Sony - PlayStation": playstationCore,
},
FileDirectory: usr.HomeDir,
CoresDirectory: "./cores",
AssetsDirectory: "./assets",
DatabaseDirectory: "./database",
Expand Down
1 change: 1 addition & 0 deletions settings/settings.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ type Settings struct {

CoreForPlaylist map[string]string `hide:"always" toml:"core_for_playlist"`

FileDirectory string `hide:"ludos" toml:"files_dir" label:"Files Directory" fmt:"%s" widget:"dir"`
CoresDirectory string `hide:"ludos" toml:"cores_dir" label:"Cores Directory" fmt:"%s" widget:"dir"`
AssetsDirectory string `hide:"ludos" toml:"assets_dir" label:"Assets Directory" fmt:"%s" widget:"dir"`
DatabaseDirectory string `hide:"ludos" toml:"database_dir" label:"Database Directory" fmt:"%s" widget:"dir"`
Expand Down

0 comments on commit ad635fb

Please sign in to comment.