added option to show/hide file extensions

updated doc
This commit is contained in:
Thomas Jentzsch 2021-11-25 11:07:19 +01:00
parent dc10ca9c00
commit 596522de8c
14 changed files with 97 additions and 18 deletions

View File

@ -16,7 +16,9 @@
* Added option to toggle autofire mode. * Added option to toggle autofire mode.
* Added icons to file lists (TODO: doc) * Added icons to file lists.
* Added option to show/hide file extensions.
-Have fun! -Have fun!

Binary file not shown.

Before

Width:  |  Height:  |  Size: 14 KiB

After

Width:  |  Height:  |  Size: 41 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.5 KiB

After

Width:  |  Height:  |  Size: 3.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 44 KiB

After

Width:  |  Height:  |  Size: 45 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 36 KiB

After

Width:  |  Height:  |  Size: 36 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 74 KiB

After

Width:  |  Height:  |  Size: 74 KiB

View File

@ -2278,6 +2278,11 @@
<td>Control + R</td> <td>Control + R</td>
<td>Control + R</td> <td>Control + R</td>
</tr> </tr>
<tr>
<td>Toggle file extensions display</td>
<td>Control + X</td>
<td>Control + X</td>
</tr>
</table> </table>
<p><b>UI Keys in Text Editing areas (cannot be remapped)</b></p> <p><b>UI Keys in Text Editing areas (cannot be remapped)</b></p>
@ -3229,6 +3234,17 @@
files in the ROM launcher.</td> files in the ROM launcher.</td>
</tr> </tr>
<tr>
<td><pre>-launcherextensions &lt;1|0&gt;</pre></td>
<td>Display file extensions in the ROM launcher.</td>
</tr>
<tr>
<td><pre>-launchersubdirs &lt;1|0&gt;</pre></td>
<td>Specifies whether the ROM launcher lists files from current
directory only or all subdirectories too.</td>
</tr>
<tr> <tr>
<td><pre>-romviewer &lt;float&gt;</pre></td> <td><pre>-romviewer &lt;float&gt;</pre></td>
<td>Hide ROM Info Viewer in ROM launcher mode (0) or use the <td>Hide ROM Info Viewer in ROM launcher mode (0) or use the
@ -4157,7 +4173,7 @@
<p>ROM Info Viewer width at 40%, UI sized 800x480, small launcher font:</p> <p>ROM Info Viewer width at 40%, UI sized 800x480, small launcher font:</p>
<img src="graphics/rominfo_1x_small.png"> <img src="graphics/rominfo_1x_small.png">
<p>ROM Info Viewer width at 32%, UI sized 1000x720, medium launcher font:</p> <p>ROM Info Viewer width at 32%, UI sized 900x720, medium launcher font:</p>
<img src="graphics/rominfo_1x_large.png"> <img src="graphics/rominfo_1x_large.png">
<p>ROM Info Viewer width at 50% , UI sized 1280x900, large launcher font:</p> <p>ROM Info Viewer width at 50% , UI sized 1280x900, large launcher font:</p>

View File

@ -154,6 +154,7 @@ Settings::Settings()
setPermanent("launcherfont", "medium"); setPermanent("launcherfont", "medium");
setPermanent("launcherroms", "true"); setPermanent("launcherroms", "true");
setPermanent("launchersubdirs", "false"); setPermanent("launchersubdirs", "false");
setPermanent("launcherextensions", "false");
setPermanent("romviewer", "1"); setPermanent("romviewer", "1");
setPermanent("lastrom", ""); setPermanent("lastrom", "");
@ -579,7 +580,8 @@ void Settings::usage() const
<< " entry\n" << " entry\n"
<< endl << endl
<< " -exitlauncher <0|1> On exiting a ROM, go back to the ROM launcher\n" << " -exitlauncher <0|1> On exiting a ROM, go back to the ROM launcher\n"
<< " -launcherpos <XxY> Sets the window position in windowed EOM launcher mode\n" << " -launcherpos <XxY> Sets the window position in windowed launcher\n"
<< " mode\n"
<< " -launcherdisplay <number> Sets the display for the ROM launcher\n" << " -launcherdisplay <number> Sets the display for the ROM launcher\n"
<< " -launcherres <WxH> The resolution to use in ROM launcher mode\n" << " -launcherres <WxH> The resolution to use in ROM launcher mode\n"
<< " -launcherfont <small| Use the specified font in the ROM launcher\n" << " -launcherfont <small| Use the specified font in the ROM launcher\n"
@ -589,13 +591,14 @@ void Settings::usage() const
<< " large16>\n" << " large16>\n"
<< " -romviewer <float> Show ROM info viewer at given zoom level in ROM\n" << " -romviewer <float> Show ROM info viewer at given zoom level in ROM\n"
<< " launcher (use 0 for off)\n" << " launcher (use 0 for off)\n"
<< " -launcherroms <1|0> Show only ROMs in the launcher (vs. all files)\n" << " -launcherroms <1|0> Show only ROMs in the launcher (vs. all files)\n"
<< " -launchersubdirs <0|1> Show files from subdirectories too\n" << " -launchersubdirs <0|1> Show files from subdirectories too\n"
<< " -romdir <dir> Set the path where the ROM launcher will start\n" << " -launcherextensions <0|1> Display file extensions in launcher\n"
<< " -followlauncher <0|1> Default ROM path follows launcher navigation\n" << " -romdir <dir> Set the path where the ROM launcher will start\n"
<< " -userdir <dir> Set the path to save user files to\n" << " -followlauncher <0|1> Default ROM path follows launcher navigation\n"
<< " -saveuserdir <0|1> Update user path when navigating in browser\n" << " -userdir <dir> Set the path to save user files to\n"
<< " -lastrom <name> Last played ROM, automatically selected in\n" << " -saveuserdir <0|1> Update user path when navigating in browser\n"
<< " -lastrom <name> Last played ROM, automatically selected in\n"
<< " launcher\n" << " launcher\n"
<< " -romloadcount <number> Number of ROM to load next from multicard\n" << " -romloadcount <number> Number of ROM to load next from multicard\n"
<< " -uipalette <standard| Selects GUI theme\n" << " -uipalette <standard| Selects GUI theme\n"

View File

@ -106,8 +106,8 @@ void FileListWidget::setLocation(const FilesystemNode& node,
{ {
const string path = file.getShortPath(); const string path = file.getShortPath();
const string name = file.getName(); const string name = file.getName();
const string displayName = _showFileExtensions ? name : file.getNameWithExt(EmptyString);
l.push_back(name);
// display only relative path in tooltip // display only relative path in tooltip
if(path.length() >= orgLen) if(path.length() >= orgLen)
_dirList.push_back(path.substr(orgLen)); _dirList.push_back(path.substr(orgLen));
@ -116,14 +116,24 @@ void FileListWidget::setLocation(const FilesystemNode& node,
if(file.isDirectory()) if(file.isDirectory())
{ {
if(BSPF::endsWithIgnoreCase(name, ".zip")) if(BSPF::endsWithIgnoreCase(name, ".zip"))
{
l.push_back(displayName);
_iconList.push_back(IconType::zip); _iconList.push_back(IconType::zip);
}
else else
{
l.push_back(name);
_iconList.push_back(IconType::directory); _iconList.push_back(IconType::directory);
}
} }
else if(file.isFile() && Bankswitch::isValidRomName(name))
_iconList.push_back(IconType::rom);
else else
_iconList.push_back(IconType::unknown); {
l.push_back(displayName);
if(file.isFile() && Bankswitch::isValidRomName(name))
_iconList.push_back(IconType::rom);
else
_iconList.push_back(IconType::unknown);
}
} }
setList(l); setList(l);
@ -152,7 +162,10 @@ void FileListWidget::reload()
{ {
if(_node.exists()) if(_node.exists())
{ {
_selectedFile = selected().getName(); if(_showFileExtensions || selected().isDirectory())
_selectedFile = selected().getName();
else
_selectedFile = selected().getNameWithExt(EmptyString);
setLocation(_node, _selectedFile); setLocation(_node, _selectedFile);
} }
} }

View File

@ -65,6 +65,9 @@ class FileListWidget : public StringListWidget
// When enabled, all subdirectories will be searched too. // When enabled, all subdirectories will be searched too.
void setIncludeSubDirs(bool enable) { _includeSubDirs = enable; } void setIncludeSubDirs(bool enable) { _includeSubDirs = enable; }
// When enabled, file extensions will be displayed too.
void setShowFileExtensions(bool enable) { _showFileExtensions = enable; }
/** /**
Set initial directory, and optionally select the given item. Set initial directory, and optionally select the given item.
@ -121,6 +124,7 @@ class FileListWidget : public StringListWidget
FilesystemNode _node; FilesystemNode _node;
FSList _fileList; FSList _fileList;
bool _includeSubDirs{false}; bool _includeSubDirs{false};
bool _showFileExtensions{true};
StringList _dirList; StringList _dirList;
IconTypeList _iconList; IconTypeList _iconList;

View File

@ -348,7 +348,12 @@ const FilesystemNode& LauncherDialog::currentDir() const
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void LauncherDialog::reload() void LauncherDialog::reload()
{ {
bool subDirs = instance().settings().getBool("launchersubdirs");
bool extensions = instance().settings().getBool("launcherextensions");
myMD5List.clear(); myMD5List.clear();
myList->setIncludeSubDirs(subDirs);
myList->setShowFileExtensions(extensions);
myList->reload(); myList->reload();
myPendingReload = false; myPendingReload = false;
} }
@ -380,8 +385,11 @@ void LauncherDialog::loadConfig()
} }
bool subDirs = instance().settings().getBool("launchersubdirs"); bool subDirs = instance().settings().getBool("launchersubdirs");
bool extensions = instance().settings().getBool("launcherextensions");
if (mySubDirs) mySubDirs->setState(subDirs); if (mySubDirs) mySubDirs->setState(subDirs);
myList->setIncludeSubDirs(subDirs); myList->setIncludeSubDirs(subDirs);
myList->setShowFileExtensions(extensions);
// Assume that if the list is empty, this is the first time that loadConfig() // Assume that if the list is empty, this is the first time that loadConfig()
// has been called (and we should reload the list) // has been called (and we should reload the list)
@ -663,6 +671,16 @@ void LauncherDialog::handleKeyDown(StellaKey key, StellaMod mod, bool repeated)
reload(); reload();
break; break;
case KBDK_X:
{
bool extensions = !instance().settings().getBool("launcherextensions");
instance().settings().setValue("launcherextensions", extensions);
myList->setShowFileExtensions(extensions);
reload();
break;
}
default: default:
handled = false; handled = false;
break; break;
@ -867,6 +885,10 @@ void LauncherDialog::handleCommand(CommandSender* sender, int cmd,
break; break;
} }
case kExtChangedCmd:
reload();
break;
case ContextMenu::kItemSelectedCmd: case ContextMenu::kItemSelectedCmd:
handleContextMenu(); handleContextMenu();
break; break;

View File

@ -47,7 +47,8 @@ class LauncherDialog : public Dialog
// These must be accessible from dialogs created by this class // These must be accessible from dialogs created by this class
enum { enum {
kLoadROMCmd = 'STRT', // load currently selected ROM kLoadROMCmd = 'STRT', // load currently selected ROM
kRomDirChosenCmd = 'romc' // rom dir chosen kRomDirChosenCmd = 'romc', // ROM dir chosen
kExtChangedCmd = 'extc' // File extension display changed
}; };
public: public:

View File

@ -254,6 +254,13 @@ UIDialog::UIDialog(OSystem& osystem, DialogContainer& parent,
new PopUpWidget(myTab, font, xpos, ypos + 1, pwidth, lineHeight, items, new PopUpWidget(myTab, font, xpos, ypos + 1, pwidth, lineHeight, items,
"Launcher font ", lwidth); "Launcher font ", lwidth);
wid.push_back(myLauncherFontPopup); wid.push_back(myLauncherFontPopup);
// Display launcher extensions
ypos += lineHeight + VGAP;
myLauncherExtensionsWidget = new CheckboxWidget(myTab, _font, xpos, ypos + 1,
"Display file extensions");
wid.push_back(myLauncherExtensionsWidget);
ypos += lineHeight + VGAP * 4; ypos += lineHeight + VGAP * 4;
// ROM launcher info/snapshot viewer // ROM launcher info/snapshot viewer
@ -352,6 +359,8 @@ void UIDialog::loadConfig()
const string& launcherFont = settings.getString("launcherfont"); const string& launcherFont = settings.getString("launcherfont");
myLauncherFontPopup->setSelected(launcherFont, "medium"); myLauncherFontPopup->setSelected(launcherFont, "medium");
myLauncherExtensionsWidget->setState(settings.getBool("launcherextensions"));
// ROM launcher info viewer // ROM launcher info viewer
float zoom = instance().settings().getFloat("romviewer"); float zoom = instance().settings().getFloat("romviewer");
int percentage = zoom * TIAConstants::viewableWidth * 100 / w; int percentage = zoom * TIAConstants::viewableWidth * 100 / w;
@ -435,6 +444,9 @@ void UIDialog::saveConfig()
settings.setValue("launcherfont", settings.setValue("launcherfont",
myLauncherFontPopup->getSelectedTag().toString()); myLauncherFontPopup->getSelectedTag().toString());
// Display launcher extensions
settings.setValue("launcherextensions", myLauncherExtensionsWidget->getState());
// ROM launcher info viewer // ROM launcher info viewer
int w = myLauncherWidthSlider->getValue(); int w = myLauncherWidthSlider->getValue();
float zoom = myRomViewerSize->getValue() * w / 100.F / TIAConstants::viewableWidth; float zoom = myRomViewerSize->getValue() * w / 100.F / TIAConstants::viewableWidth;
@ -518,6 +530,7 @@ void UIDialog::setDefaults()
myLauncherWidthSlider->setValue(w); myLauncherWidthSlider->setValue(w);
myLauncherHeightSlider->setValue(h); myLauncherHeightSlider->setValue(h);
myLauncherFontPopup->setSelected("medium", ""); myLauncherFontPopup->setSelected("medium", "");
myLauncherExtensionsWidget->setState(false);
myRomViewerSize->setValue(35); myRomViewerSize->setValue(35);
mySnapLoadPath->setText(instance().userDir().getShortPath()); mySnapLoadPath->setText(instance().userDir().getShortPath());
myLauncherExitWidget->setState(false); myLauncherExitWidget->setState(false);
@ -535,12 +548,16 @@ void UIDialog::handleCommand(CommandSender* sender, int cmd, int data, int id)
{ {
case GuiObject::kOKCmd: case GuiObject::kOKCmd:
{ {
bool inform = myIsGlobal && bool informPath = myIsGlobal &&
myRomPath->getText() != instance().settings().getString("romdir"); myRomPath->getText() != instance().settings().getString("romdir");
bool informExt = myIsGlobal &&
myLauncherExtensionsWidget->getState() != instance().settings().getBool("launcherextensions");
saveConfig(); saveConfig();
close(); close();
if(inform) // Let the boss know romdir has changed if(informPath) // Let the boss know romdir has changed
sendCommand(LauncherDialog::kRomDirChosenCmd, 0, 0); sendCommand(LauncherDialog::kRomDirChosenCmd, 0, 0);
if(informExt) // Let the boss know the file extension display setting has changed
sendCommand(LauncherDialog::kExtChangedCmd, 0, 0);
break; break;
} }
case GuiObject::kDefaultsCmd: case GuiObject::kDefaultsCmd:

View File

@ -57,6 +57,7 @@ class UIDialog : public Dialog, public CommandSender
SliderWidget* myLauncherWidthSlider{nullptr}; SliderWidget* myLauncherWidthSlider{nullptr};
SliderWidget* myLauncherHeightSlider{nullptr}; SliderWidget* myLauncherHeightSlider{nullptr};
PopUpWidget* myLauncherFontPopup{nullptr}; PopUpWidget* myLauncherFontPopup{nullptr};
CheckboxWidget* myLauncherExtensionsWidget{nullptr};
SliderWidget* myRomViewerSize{nullptr}; SliderWidget* myRomViewerSize{nullptr};
ButtonWidget* myOpenBrowserButton{nullptr}; ButtonWidget* myOpenBrowserButton{nullptr};
EditTextWidget* mySnapLoadPath{nullptr}; EditTextWidget* mySnapLoadPath{nullptr};