mirror of
https://github.com/JetSetIlly/Gopher2600.git
synced 2024-05-20 05:40:49 -04:00
cartridge names have file extensions clipped only if the extension is in
the list of known/supported file extensions
This commit is contained in:
parent
e47c37bd98
commit
37ce7bc244
|
@ -17,6 +17,7 @@ package cartridgeloader
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
"slices"
|
||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -40,6 +41,9 @@ func decideOnName(ld Loader) string {
|
||||||
// is inconvenient.
|
// is inconvenient.
|
||||||
func NameFromFilename(filename string) string {
|
func NameFromFilename(filename string) string {
|
||||||
name := filepath.Base(filename)
|
name := filepath.Base(filename)
|
||||||
name = strings.TrimSuffix(name, filepath.Ext(filename))
|
ext := filepath.Ext(filename)
|
||||||
|
if slices.Contains(FileExtensions, ext) {
|
||||||
|
name = strings.TrimSuffix(name, filepath.Ext(filename))
|
||||||
|
}
|
||||||
return name
|
return name
|
||||||
}
|
}
|
||||||
|
|
|
@ -258,7 +258,7 @@ func (win *winSelectROM) draw() {
|
||||||
win.selectedName = win.selectedProperties.Name
|
win.selectedName = win.selectedProperties.Name
|
||||||
if win.selectedName == "" {
|
if win.selectedName == "" {
|
||||||
win.selectedName = win.path.Base()
|
win.selectedName = win.path.Base()
|
||||||
win.selectedName = strings.TrimSuffix(win.selectedName, filepath.Ext(win.selectedName))
|
win.selectedName = cartridgeloader.NameFromFilename(win.selectedName)
|
||||||
}
|
}
|
||||||
|
|
||||||
// normalise ROM name for presentation
|
// normalise ROM name for presentation
|
||||||
|
@ -588,6 +588,11 @@ func (win *winSelectROM) draw() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
imgui.Spacing()
|
||||||
|
imgui.Checkbox("Show All", &win.showAllFiles)
|
||||||
|
imgui.SameLine()
|
||||||
|
imgui.Checkbox("Show Hidden", &win.showHidden)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -622,9 +627,6 @@ func (win *winSelectROM) setPath(path string) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (win *winSelectROM) setSelectedFile(filename string) {
|
func (win *winSelectROM) setSelectedFile(filename string) {
|
||||||
// selected name will be
|
|
||||||
win.selectedName = ""
|
|
||||||
|
|
||||||
// return immediately if the filename is empty
|
// return immediately if the filename is empty
|
||||||
if filename == "" {
|
if filename == "" {
|
||||||
return
|
return
|
||||||
|
|
Loading…
Reference in a new issue