@@ -43,6 +43,24 @@ func NewPlatformMappingScreen() *PlatformMappingScreen {
4343 return & PlatformMappingScreen {}
4444}
4545
46+ // distinctPlatformValues returns the sorted, deduplicated, non-empty values produced
47+ // by get across platforms. An empty result means the corresponding metadata filter has
48+ // no options and should be hidden rather than shown as an "All"-only picker.
49+ func distinctPlatformValues (platforms []romm.Platform , get func (romm.Platform ) string ) []string {
50+ set := make (map [string ]bool )
51+ for _ , p := range platforms {
52+ if v := get (p ); v != "" {
53+ set [v ] = true
54+ }
55+ }
56+ values := make ([]string , 0 , len (set ))
57+ for v := range set {
58+ values = append (values , v )
59+ }
60+ slices .Sort (values )
61+ return values
62+ }
63+
4664func (s * PlatformMappingScreen ) Draw (input PlatformMappingInput ) (PlatformMappingOutput , error ) {
4765 logger := gaba .GetLogger ()
4866 output := PlatformMappingOutput {Action : PlatformMappingActionBack , Mappings : make (map [string ]internal.DirectoryMapping )}
@@ -223,17 +241,7 @@ func (s *PlatformMappingScreen) Draw(input PlatformMappingInput) (PlatformMappin
223241 }
224242
225243 // Build dynamic list of categories present in rommPlatforms
226- categorySet := make (map [string ]bool )
227- for _ , p := range rommPlatforms {
228- if p .Category != "" {
229- categorySet [p .Category ] = true
230- }
231- }
232- var uniqueCategories []string
233- for c := range categorySet {
234- uniqueCategories = append (uniqueCategories , c )
235- }
236- slices .Sort (uniqueCategories )
244+ uniqueCategories := distinctPlatformValues (rommPlatforms , func (p romm.Platform ) string { return p .Category })
237245
238246 categoryOptions := []gaba.Option {
239247 {DisplayName : i18n .Localize (& goi18n.Message {ID : "filter_all" , Other : "All" }, nil ), Value : "all" },
@@ -250,17 +258,7 @@ func (s *PlatformMappingScreen) Draw(input PlatformMappingInput) (PlatformMappin
250258 }
251259
252260 // Build dynamic list of families present in rommPlatforms
253- familySet := make (map [string ]bool )
254- for _ , p := range rommPlatforms {
255- if p .Family != "" {
256- familySet [p .Family ] = true
257- }
258- }
259- var uniqueFamilies []string
260- for f := range familySet {
261- uniqueFamilies = append (uniqueFamilies , f )
262- }
263- slices .Sort (uniqueFamilies )
261+ uniqueFamilies := distinctPlatformValues (rommPlatforms , func (p romm.Platform ) string { return p .Family })
264262
265263 familyOptions := []gaba.Option {
266264 {DisplayName : i18n .Localize (& goi18n.Message {ID : "filter_all" , Other : "All" }, nil ), Value : "all" },
@@ -298,27 +296,38 @@ func (s *PlatformMappingScreen) Draw(input PlatformMappingInput) (PlatformMappin
298296 },
299297 SelectedOption : boolToIndex (showGamesOnlySub ),
300298 },
301- {
299+ }
300+
301+ // Only show a metadata filter when RomM actually populated values for it —
302+ // otherwise it's a useless "All"-only picker (#247). Category/Family are
303+ // frequently empty (they require IGDB platform metadata); Generation usually
304+ // has values but is gated the same way for consistency.
305+ if len (uniqueCategories ) > 0 {
306+ filterItems = append (filterItems , gaba.ItemWithOptions {
302307 Item : gaba.MenuItem {
303308 Text : i18n .Localize (& goi18n.Message {ID : "settings_category" , Other : "Category" }, nil ),
304309 },
305310 Options : categoryOptions ,
306311 SelectedOption : categorySelectedIndex ,
307- },
308- {
312+ })
313+ }
314+ if len (uniqueFamilies ) > 0 {
315+ filterItems = append (filterItems , gaba.ItemWithOptions {
309316 Item : gaba.MenuItem {
310317 Text : i18n .Localize (& goi18n.Message {ID : "settings_family" , Other : "Family" }, nil ),
311318 },
312319 Options : familyOptions ,
313320 SelectedOption : familySelectedIndex ,
314- },
315- {
321+ })
322+ }
323+ if len (uniqueGenerations ) > 0 {
324+ filterItems = append (filterItems , gaba.ItemWithOptions {
316325 Item : gaba.MenuItem {
317326 Text : i18n .Localize (& goi18n.Message {ID : "settings_generation" , Other : "Generation" }, nil ),
318327 },
319328 Options : generationOptions ,
320329 SelectedOption : generationSelectedIndex ,
321- },
330+ })
322331 }
323332
324333 filterResult , err := gaba .OptionsList (
0 commit comments