Skip to content

Commit 362348e

Browse files
Merge remote-tracking branch 'origin/v4.8.0.0' into v4.8.0.0
2 parents f2a9737 + c92b305 commit 362348e

14 files changed

Lines changed: 764 additions & 34 deletions

File tree

cfw/batocera/batocera.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,3 +40,15 @@ func GetArtDirectory(romDir string) string {
4040
func GetGroutGamelist() string {
4141
return filepath.Join(GetRomDirectory(), "ports", "gamelist.xml")
4242
}
43+
44+
func GetVideoDirectory(romDir string) string {
45+
return filepath.Join(romDir, "videos")
46+
}
47+
48+
func GetBezelDirectory(romDir string) string {
49+
return filepath.Join(romDir, "bezels")
50+
}
51+
52+
func GetManualDirectory(romDir string) string {
53+
return filepath.Join(romDir, "manuals")
54+
}

cfw/cfw.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,12 @@ func GetCFW() CFW {
3434
return ""
3535
}
3636
}
37+
38+
func (c CFW) IsBasedOnEmulationStation() bool {
39+
switch c {
40+
case Knulli, ROCKNIX, Batocera:
41+
return true
42+
default:
43+
return false
44+
}
45+
}

cfw/directories.go

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,3 +174,95 @@ func BaseSavePath() string {
174174
}
175175
return ""
176176
}
177+
178+
func GetArtMarqueeDirectory(romDir string, platformFSSlug, platformName string) string {
179+
switch GetCFW() {
180+
case ROCKNIX:
181+
return rocknix.GetArtDirectory(romDir)
182+
case Knulli:
183+
return knulli.GetArtDirectory(romDir)
184+
case Batocera:
185+
return batocera.GetArtDirectory(romDir)
186+
default:
187+
return ""
188+
}
189+
}
190+
191+
func GetArtVideoDirectory(romDir string, platformFSSlug, platformName string) string {
192+
switch GetCFW() {
193+
case ROCKNIX:
194+
return rocknix.GetVideoDirectory(romDir)
195+
case Knulli:
196+
return knulli.GetVideoDirectory(romDir)
197+
case Batocera:
198+
return batocera.GetVideoDirectory(romDir)
199+
default:
200+
return ""
201+
202+
}
203+
}
204+
205+
func GetArtThumbnailDirectory(romDir string, platformFSSlug, platformName string) string {
206+
switch GetCFW() {
207+
case ROCKNIX:
208+
return rocknix.GetArtDirectory(romDir)
209+
case Knulli:
210+
return knulli.GetArtDirectory(romDir)
211+
case Batocera:
212+
return knulli.GetArtDirectory(romDir)
213+
default:
214+
return ""
215+
}
216+
}
217+
218+
func GetArtBezelDirectory(romDir string, platformFSSlug, platformName string) string {
219+
switch GetCFW() {
220+
case ROCKNIX:
221+
return rocknix.GetBezelDirectory(romDir)
222+
case Knulli:
223+
return knulli.GetBezelDirectory(romDir)
224+
case Batocera:
225+
return batocera.GetBezelDirectory(romDir)
226+
default:
227+
return ""
228+
}
229+
}
230+
231+
func GetManualDirectory(romDir string, platformFSSlug, platformName string) string {
232+
switch GetCFW() {
233+
case ROCKNIX:
234+
return rocknix.GetManualDirectory(romDir)
235+
case Knulli:
236+
return knulli.GetManualDirectory(romDir)
237+
case Batocera:
238+
return batocera.GetManualDirectory(romDir)
239+
default:
240+
return ""
241+
}
242+
}
243+
244+
func GetBoxbackDirectory(romDir string, platformFSSlug, platformName string) string {
245+
switch GetCFW() {
246+
case ROCKNIX:
247+
return rocknix.GetArtDirectory(romDir)
248+
case Knulli:
249+
return knulli.GetArtDirectory(romDir)
250+
case Batocera:
251+
return batocera.GetArtDirectory(romDir)
252+
default:
253+
return ""
254+
}
255+
}
256+
257+
func GetFanartDirectory(romDir string, platformFSSlug, platformName string) string {
258+
switch GetCFW() {
259+
case ROCKNIX:
260+
return rocknix.GetArtDirectory(romDir)
261+
case Knulli:
262+
return knulli.GetArtDirectory(romDir)
263+
case Batocera:
264+
return batocera.GetArtDirectory(romDir)
265+
default:
266+
return ""
267+
}
268+
}

cfw/knulli/knulli.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,3 +40,15 @@ func GetArtDirectory(romDir string) string {
4040
func GetGroutGamelist() string {
4141
return filepath.Join(GetRomDirectory(), "tools", "gamelist.xml")
4242
}
43+
44+
func GetVideoDirectory(romDir string) string {
45+
return filepath.Join(romDir, "videos")
46+
}
47+
48+
func GetManualDirectory(romDir string) string {
49+
return filepath.Join(romDir, "manuals")
50+
}
51+
52+
func GetBezelDirectory(romDir string) string {
53+
return filepath.Join(romDir, "bezels")
54+
}

cfw/rocknix/rocknix.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,15 @@ func GetArtDirectory(romDir string) string {
4141
func GetGroutGamelist() string {
4242
return filepath.Join(GetRomDirectory(), "ports", "gamelist.xml")
4343
}
44+
45+
func GetVideoDirectory(romDir string) string {
46+
return filepath.Join(romDir, "videos")
47+
}
48+
49+
func GetManualDirectory(romDir string) string {
50+
return filepath.Join(romDir, "manuals")
51+
}
52+
53+
func GetBezelDirectory(romDir string) string {
54+
return filepath.Join(romDir, "bezels")
55+
}

internal/artutil/artutil.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ const (
99
ArtKindBox3D ArtKind = "Box3D"
1010
ArtKindMixImage ArtKind = "Miximage"
1111
ArtKindMarquee ArtKind = "Marquee"
12+
ArtKindLogo ArtKind = "Logo"
1213
ArtKindTitle ArtKind = "Title"
1314
ArtKindScreenshot ArtKind = "Screenshot"
1415
ArtKindVideo ArtKind = "Video"

internal/config.go

Lines changed: 64 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,16 @@ import (
1717

1818
var kidModeEnabled atomic.Bool
1919

20+
type AdditionalDownloads struct {
21+
Marquee artutil.ArtKind `json:"marquee,omitempty"`
22+
Video bool `json:"video,omitempty"`
23+
Thumbnail artutil.ArtKind `json:"thumbnail,omitempty"`
24+
Bezel bool `json:"bezel,omitempty"`
25+
Manual bool `json:"manual,omitempty"`
26+
BoxBack bool `json:"box_back,omitempty"`
27+
Fanart bool `json:"fanart,omitempty"`
28+
}
29+
2030
// DurationSeconds is a time.Duration that marshals to/from JSON as whole seconds.
2131
// Existing configs with nanosecond values are handled by detecting large values on unmarshal.
2232
type DurationSeconds time.Duration
@@ -54,8 +64,8 @@ type Config struct {
5464
ShowSmartCollections bool `json:"show_smart_collections"`
5565
ShowVirtualCollections bool `json:"show_virtual_collections"`
5666
DownloadedGames DownloadedGamesMode `json:"downloaded_games,omitempty"`
57-
ApiTimeout DurationSeconds `json:"api_timeout"`
58-
DownloadTimeout DurationSeconds `json:"download_timeout"`
67+
ApiTimeout DurationSeconds `json:"api_timeout"`
68+
DownloadTimeout DurationSeconds `json:"download_timeout"`
5969
LogLevel LogLevel `json:"log_level,omitempty"`
6070
Language string `json:"language,omitempty"`
6171
CollectionView CollectionView `json:"collection_view,omitempty"`
@@ -64,6 +74,7 @@ type Config struct {
6474
ArtKind artutil.ArtKind `json:"art_kind,omitempty"`
6575
DownloadArtScreenshotPreview bool `json:"download_art_screenshot_preview,omitempty"`
6676
DownloadSplashArt artutil.ArtKind `json:"download_splash_art,omitempty"`
77+
AdditionalDownloads AdditionalDownloads `json:"additional_downloads,omitempty"`
6778

6879
SwapFaceButtons bool `json:"swap_face_buttons,omitempty"`
6980
PlatformOrder []string `json:"platform_order,omitempty"`
@@ -142,6 +153,14 @@ func LoadConfig() (*Config, error) {
142153
config.ArtKind = artutil.ArtKindDefault
143154
}
144155

156+
if config.AdditionalDownloads.Thumbnail == "" {
157+
config.AdditionalDownloads.Thumbnail = artutil.ArtKindNone
158+
}
159+
160+
if config.AdditionalDownloads.Marquee == "" {
161+
config.AdditionalDownloads.Marquee = artutil.ArtKindNone
162+
}
163+
145164
// Load slot preferences from dedicated file
146165
config.SlotPreferences = LoadSlotPreferences()
147166

@@ -173,6 +192,14 @@ func SaveConfig(config *Config) error {
173192
config.ArtKind = artutil.ArtKindDefault
174193
}
175194

195+
if config.AdditionalDownloads.Thumbnail == "" {
196+
config.AdditionalDownloads.Thumbnail = artutil.ArtKindNone
197+
}
198+
199+
if config.AdditionalDownloads.Marquee == "" {
200+
config.AdditionalDownloads.Marquee = artutil.ArtKindNone
201+
}
202+
176203
gaba.SetRawLogLevel(string(config.LogLevel))
177204

178205
if err := i18n.SetWithCode(config.Language); err != nil {
@@ -337,6 +364,41 @@ func (c Config) GetArtSplashDirectory(platform romm.Platform) string {
337364
return cfw.GetArtSplashDirectory(romDir, platform.FSSlug, platform.Name)
338365
}
339366

367+
func (c Config) GetArtMarqueeDirectory(platform romm.Platform) string {
368+
romDir := c.GetPlatformRomDirectory(platform)
369+
return cfw.GetArtMarqueeDirectory(romDir, platform.FSSlug, platform.Name)
370+
}
371+
372+
func (c Config) GetArtVideoDirectory(platform romm.Platform) string {
373+
romDir := c.GetPlatformRomDirectory(platform)
374+
return cfw.GetArtVideoDirectory(romDir, platform.FSSlug, platform.Name)
375+
}
376+
377+
func (c Config) GetArtThumbnailDirectory(platform romm.Platform) string {
378+
romDir := c.GetPlatformRomDirectory(platform)
379+
return cfw.GetArtThumbnailDirectory(romDir, platform.FSSlug, platform.Name)
380+
}
381+
382+
func (c Config) GetArtBezelDirectory(platform romm.Platform) string {
383+
romDir := c.GetPlatformRomDirectory(platform)
384+
return cfw.GetArtBezelDirectory(romDir, platform.FSSlug, platform.Name)
385+
}
386+
387+
func (c Config) GetManualDirectory(platform romm.Platform) string {
388+
romDir := c.GetPlatformRomDirectory(platform)
389+
return cfw.GetManualDirectory(romDir, platform.FSSlug, platform.Name)
390+
}
391+
392+
func (c Config) GetFanartDirectory(platform romm.Platform) string {
393+
romDir := c.GetPlatformRomDirectory(platform)
394+
return cfw.GetFanartDirectory(romDir, platform.FSSlug, platform.Name)
395+
}
396+
397+
func (c Config) GetBoxbackDirectory(platform romm.Platform) string {
398+
romDir := c.GetPlatformRomDirectory(platform)
399+
return cfw.GetBoxbackDirectory(romDir, platform.FSSlug, platform.Name)
400+
}
401+
340402
func (c Config) ShowCollections(host romm.Host) bool {
341403
if !c.ShowRegularCollections && !c.ShowSmartCollections && !c.ShowVirtualCollections {
342404
return false

internal/gamelist/add.go

Lines changed: 57 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"grout/internal/stringutil"
77
"grout/romm"
88
"os"
9+
"strconv"
910
"strings"
1011
"time"
1112

@@ -17,9 +18,20 @@ type GameListEntry struct {
1718
Path string
1819
}
1920

21+
type artLocation struct {
22+
ImagePath string
23+
MarqueePath string
24+
VideoPath string
25+
BezelPath string
26+
ManualPath string
27+
BoxBackPath string
28+
FanartPath string
29+
ThumbnailPath string
30+
}
31+
2032
type RomGameEntry struct {
2133
Game *romm.Rom
22-
ArtLocation string
34+
ArtLocation artLocation
2335
GamePath string
2436
RomDirectory string
2537
Platform *romm.Platform
@@ -40,8 +52,36 @@ func (gl *GameList) AddRomGame(entry RomGameEntry) {
4052
gameMetadata[ReleaseDateElement] = fmt.Sprintf("%s", formatted)
4153
}
4254

43-
if entry.ArtLocation != "" {
44-
gameMetadata[ImageElement] = entry.ArtLocation
55+
if entry.ArtLocation.ImagePath != "" {
56+
gameMetadata[ImageElement] = entry.ArtLocation.ImagePath
57+
}
58+
59+
if entry.ArtLocation.ThumbnailPath != "" {
60+
gameMetadata[ThumbnailElement] = entry.ArtLocation.ThumbnailPath
61+
}
62+
63+
if entry.ArtLocation.MarqueePath != "" {
64+
gameMetadata[MarqueeElement] = entry.ArtLocation.MarqueePath
65+
}
66+
67+
if entry.ArtLocation.VideoPath != "" {
68+
gameMetadata[VideoElement] = entry.ArtLocation.VideoPath
69+
}
70+
71+
if entry.ArtLocation.BezelPath != "" {
72+
gameMetadata[BezelElement] = entry.ArtLocation.BezelPath
73+
}
74+
75+
if entry.ArtLocation.ManualPath != "" {
76+
gameMetadata[ManualElement] = entry.ArtLocation.ManualPath
77+
}
78+
79+
if entry.ArtLocation.BoxBackPath != "" {
80+
gameMetadata[BoxbackElement] = entry.ArtLocation.BoxBackPath
81+
}
82+
83+
if entry.ArtLocation.FanartPath != "" {
84+
gameMetadata[FanartElement] = entry.ArtLocation.FanartPath
4585
}
4686

4787
if entry.GamePath != "" {
@@ -73,6 +113,20 @@ func (gl *GameList) AddRomGame(entry RomGameEntry) {
73113
gameMetadata[DeveloperElement] = strings.Join(entry.Game.ScreenScraperMetadata.Companies, ", ")
74114
}
75115

116+
if entry.Game.ScreenScraperID > 0 {
117+
screenscraperID := strconv.Itoa(entry.Game.ScreenScraperID)
118+
gameMetadata[ScraperIDElement] = screenscraperID
119+
gl.SetGameID(entry.Game.Name, screenscraperID)
120+
}
121+
122+
if entry.Game.RetroAchievementsID > 0 {
123+
gameMetadata[CheevosIDElement] = strconv.Itoa(entry.Game.RetroAchievementsID)
124+
}
125+
126+
if entry.Game.RetroAchievementsHash != "" {
127+
gameMetadata[CheevosHashElement] = entry.Game.RetroAchievementsHash
128+
}
129+
76130
gl.AdddOrUpdateEntry(entry.Game.Name, gameMetadata)
77131
}
78132

internal/gamelist/gamelist.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,16 @@ const (
2020
MD5Element = "md5"
2121
VideoElement = "video"
2222
MarqueeElement = "marquee"
23+
BezelElement = "bezel"
24+
ManualElement = "manual"
25+
FanartElement = "fanart"
26+
BoxbackElement = "boxback"
2327
ThumbnailElement = "thumbnail"
2428
LangElement = "lang"
2529
RegionElement = "region"
30+
CheevosHashElement = "cheevosHash"
31+
CheevosIDElement = "cheevosId"
32+
ScraperIDElement = "scraperId"
2633
)
2734

2835
type FileName string
@@ -129,3 +136,12 @@ func (gl *GameList) AdddOrUpdateEntry(name string, info map[string]string) {
129136
}
130137

131138
}
139+
140+
func (gl *GameList) SetGameID(name, id string) {
141+
game := gl.GetGameElementByName(name)
142+
if game == nil {
143+
return
144+
}
145+
146+
game.CreateAttr("id", id)
147+
}

0 commit comments

Comments
 (0)