mirror of https://github.com/stella-emu/stella.git
added option to disable favorites
This commit is contained in:
parent
b819b6102a
commit
e7b89da825
|
@ -157,6 +157,7 @@ Settings::Settings()
|
|||
setPermanent("launcherextensions", "false");
|
||||
setPermanent("romviewer", "1");
|
||||
setPermanent("lastrom", "");
|
||||
setPermanent("favorites", "true");
|
||||
setPermanent("_favoriteroms", ""); // internal only
|
||||
setPermanent("_recentroms", ""); // internal only
|
||||
setPermanent("maxrecentroms", "20");
|
||||
|
@ -600,6 +601,7 @@ void Settings::usage() const
|
|||
<< " -launcherroms <1|0> Show only ROMs in the launcher (vs. all files)\n"
|
||||
<< " -launchersubdirs <0|1> Show files from subdirectories too\n"
|
||||
<< " -launcherextensions <0|1> Display file extensions in launcher\n"
|
||||
<< " -favorites <0|1> Enable virtual favorite directories in launcher\n"
|
||||
<< " -altsorting <0|1> Alternative sorting in virtual folders\n"
|
||||
<< " -maxrecentroms <number> Number of ROMs tracked in 'Recently played'\n"
|
||||
<< " -romdir <dir> Set the path where the ROM launcher will start\n"
|
||||
|
|
|
@ -106,6 +106,14 @@ void FavoritesManager::save()
|
|||
mySettings.setValue("_popularroms", jPopular.dump(2));
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void FavoritesManager::clear()
|
||||
{
|
||||
myUserSet.clear();
|
||||
myRecentList.clear();
|
||||
myPopularMap.clear();
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void FavoritesManager::addUser(const string& path)
|
||||
{
|
||||
|
|
|
@ -43,6 +43,7 @@ class FavoritesManager
|
|||
|
||||
void load();
|
||||
void save();
|
||||
void clear();
|
||||
|
||||
// User favorites
|
||||
void addUser(const string& path);
|
||||
|
|
|
@ -708,6 +708,23 @@ void LauncherDialog::loadRomInfo()
|
|||
myRomInfoWidget->clearProperties();
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void LauncherDialog::handleFavoritesChanged()
|
||||
{
|
||||
if (instance().settings().getBool("favorites"))
|
||||
{
|
||||
myList->loadFavorites();
|
||||
}
|
||||
else
|
||||
{
|
||||
if(myList->inVirtualDir())
|
||||
myList->selectParent();
|
||||
myList->saveFavorites(true);
|
||||
myList->clearFavorites();
|
||||
}
|
||||
reload();
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void LauncherDialog::handleContextMenu()
|
||||
{
|
||||
|
@ -1022,6 +1039,10 @@ void LauncherDialog::handleCommand(CommandSender* sender, int cmd,
|
|||
break;
|
||||
}
|
||||
|
||||
case kFavChangedCmd:
|
||||
handleFavoritesChanged();
|
||||
break;
|
||||
|
||||
case kExtChangedCmd:
|
||||
reload();
|
||||
break;
|
||||
|
@ -1137,15 +1158,16 @@ void LauncherDialog::openContextMenu(int x, int y)
|
|||
};
|
||||
using ContextList = std::vector<ContextItem>;
|
||||
ContextList items;
|
||||
const bool useFavorites = instance().settings().getBool("favorites");
|
||||
|
||||
if(!currentNode().isDirectory())
|
||||
if(useFavorites && !currentNode().isDirectory())
|
||||
{
|
||||
if(myList->inRecentDir())
|
||||
items.push_back(ContextItem("Remove from recently played", "Ctrl+X", "remove"));
|
||||
if(myList->inPopularDir())
|
||||
items.push_back(ContextItem("Remove from most popular", "Ctrl+X", "remove"));
|
||||
}
|
||||
if(currentNode().isDirectory() || Bankswitch::isValidRomName(currentNode()))
|
||||
if(useFavorites && (currentNode().isDirectory() || Bankswitch::isValidRomName(currentNode())))
|
||||
items.push_back(ContextItem(myList->isUserFavorite(myList->selected().getPath())
|
||||
? "Remove from favorites"
|
||||
: "Add to favorites", "Ctrl+F", "favorite"));
|
||||
|
@ -1172,7 +1194,7 @@ void LauncherDialog::openContextMenu(int x, int y)
|
|||
items.push_back(ContextItem(instance().settings().getBool("launcherextensions")
|
||||
? "Disable file extensions"
|
||||
: "Enable file extensions", "Ctrl+E", "extensions"));
|
||||
if(myList->inVirtualDir())
|
||||
if(useFavorites && myList->inVirtualDir())
|
||||
items.push_back(ContextItem(instance().settings().getBool("altsorting")
|
||||
? "Normal sorting"
|
||||
: "Alternative sorting", "Ctrl+S", "sorting"));
|
||||
|
|
|
@ -51,6 +51,7 @@ class LauncherDialog : public Dialog
|
|||
enum {
|
||||
kLoadROMCmd = 'STRT', // load currently selected ROM
|
||||
kRomDirChosenCmd = 'romc', // ROM dir chosen
|
||||
kFavChangedCmd = 'favc', // Favorite tracking changed
|
||||
kExtChangedCmd = 'extc', // File extension display changed
|
||||
kHomeDirCmd = 'homc', // goto Home directory
|
||||
};
|
||||
|
@ -162,6 +163,7 @@ class LauncherDialog : public Dialog
|
|||
|
||||
void loadRom();
|
||||
void loadRomInfo();
|
||||
void handleFavoritesChanged();
|
||||
void handleContextMenu();
|
||||
void showOnlyROMs(bool state);
|
||||
void toggleShowAll();
|
||||
|
|
|
@ -66,7 +66,7 @@ void LauncherFileListWidget::getChildren(const FilesystemNode::CancelCheck& isCa
|
|||
myVirtualDir = EmptyString;
|
||||
FileListWidget::getChildren(isCancelled);
|
||||
}
|
||||
else
|
||||
else if(instance().settings().getBool("favorites"))
|
||||
{
|
||||
myInVirtualDir = true;
|
||||
myVirtualDir = _node.getName();
|
||||
|
@ -143,7 +143,7 @@ void LauncherFileListWidget::extendLists(StringList& list)
|
|||
else
|
||||
myRomDir = startRomDir();
|
||||
|
||||
if(_node.getPath() == myRomDir)
|
||||
if(instance().settings().getBool("favorites") && _node.getPath() == myRomDir)
|
||||
{
|
||||
// Add virtual directories behind ".."
|
||||
int offset = _fileList.begin()->getName() == ".." ? 1 : 0;
|
||||
|
@ -160,22 +160,33 @@ void LauncherFileListWidget::extendLists(StringList& list)
|
|||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void LauncherFileListWidget::loadFavorites()
|
||||
{
|
||||
myFavorites->load();
|
||||
if(instance().settings().getBool("favorites"))
|
||||
{
|
||||
myFavorites->load();
|
||||
|
||||
for(const auto& path : myFavorites->userList())
|
||||
userFavor(path);
|
||||
for (const auto& path : myFavorites->userList())
|
||||
userFavor(path);
|
||||
}
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void LauncherFileListWidget::saveFavorites()
|
||||
void LauncherFileListWidget::saveFavorites(bool force)
|
||||
{
|
||||
myFavorites->save();
|
||||
if (force || instance().settings().getBool("favorites"))
|
||||
myFavorites->save();
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void LauncherFileListWidget::clearFavorites()
|
||||
{
|
||||
myFavorites->clear();
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void LauncherFileListWidget::updateFavorites()
|
||||
{
|
||||
myFavorites->update(selected().getPath());
|
||||
if (instance().settings().getBool("favorites"))
|
||||
myFavorites->update(selected().getPath());
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
@ -187,7 +198,8 @@ bool LauncherFileListWidget::isUserFavorite(const string& path) const
|
|||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void LauncherFileListWidget::toggleUserFavorite()
|
||||
{
|
||||
if(selected().isDirectory() || Bankswitch::isValidRomName(selected()))
|
||||
if(instance().settings().getBool("favorites")
|
||||
&& (selected().isDirectory() || Bankswitch::isValidRomName(selected())))
|
||||
{
|
||||
myFavorites->toggleUser(selected().getPath());
|
||||
userFavor(selected().getPath());
|
||||
|
@ -202,10 +214,13 @@ void LauncherFileListWidget::toggleUserFavorite()
|
|||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void LauncherFileListWidget::removeFavorite()
|
||||
{
|
||||
if(inRecentDir())
|
||||
myFavorites->removeRecent(selected().getPath());
|
||||
else if(inPopularDir())
|
||||
myFavorites->removePopular(selected().getPath());
|
||||
if (instance().settings().getBool("favorites"))
|
||||
{
|
||||
if (inRecentDir())
|
||||
myFavorites->removeRecent(selected().getPath());
|
||||
else if (inPopularDir())
|
||||
myFavorites->removePopular(selected().getPath());
|
||||
}
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
|
|
@ -43,7 +43,8 @@ class LauncherFileListWidget : public FileListWidget
|
|||
void selectDirectory() override;
|
||||
|
||||
void loadFavorites();
|
||||
void saveFavorites();
|
||||
void saveFavorites(bool force = false);
|
||||
void clearFavorites();
|
||||
void updateFavorites();
|
||||
bool isUserFavorite(const string& path) const;
|
||||
void toggleUserFavorite();
|
||||
|
|
|
@ -216,14 +216,31 @@ UIDialog::UIDialog(OSystem& osystem, DialogContainer& parent,
|
|||
_w - xpos - HBORDER - 2, lineHeight, "");
|
||||
wid.push_back(myRomPath);
|
||||
|
||||
xpos = _w - HBORDER - font.getStringWidth("Follow Launcher path") - CheckboxWidget::prefixSize(font) - 1;
|
||||
const int xpos2 = _w - HBORDER - font.getStringWidth("Display file extensions")
|
||||
- CheckboxWidget::prefixSize(font) - 1;
|
||||
ypos += lineHeight + VGAP * 2;
|
||||
myFollowLauncherWidget = new CheckboxWidget(myTab, font, xpos, ypos, "Follow Launcher path");
|
||||
myFollowLauncherWidget = new CheckboxWidget(myTab, font, xpos2, ypos, "Follow Launcher path");
|
||||
myFollowLauncherWidget->setToolTip("The ROM path is updated during Launcher navigation.");
|
||||
wid.push_back(myFollowLauncherWidget);
|
||||
|
||||
xpos = HBORDER;
|
||||
ypos += VGAP * 2;
|
||||
ypos += VGAP * 4;
|
||||
|
||||
// Launcher font
|
||||
pwidth = font.getStringWidth("2x (1000x760)");
|
||||
items.clear();
|
||||
VarList::push_back(items, "Small", "small"); // 8x13
|
||||
VarList::push_back(items, "Low Medium", "low_medium"); // 9x15
|
||||
VarList::push_back(items, "Medium", "medium"); // 9x18
|
||||
VarList::push_back(items, "Large (10pt)", "large"); // 10x20
|
||||
VarList::push_back(items, "Large (12pt)", "large12"); // 12x24
|
||||
VarList::push_back(items, "Large (14pt)", "large14"); // 14x28
|
||||
VarList::push_back(items, "Large (16pt)", "large16"); // 16x32
|
||||
myLauncherFontPopup =
|
||||
new PopUpWidget(myTab, font, xpos, ypos + 1, pwidth, lineHeight, items,
|
||||
"Launcher font ", lwidth);
|
||||
wid.push_back(myLauncherFontPopup);
|
||||
ypos += lineHeight + VGAP;
|
||||
|
||||
// Launcher width and height
|
||||
myLauncherWidthSlider = new SliderWidget(myTab, font, xpos, ypos, "Launcher width ",
|
||||
|
@ -240,30 +257,21 @@ UIDialog::UIDialog(OSystem& osystem, DialogContainer& parent,
|
|||
wid.push_back(myLauncherHeightSlider);
|
||||
ypos += lineHeight + VGAP;
|
||||
|
||||
// Launcher font
|
||||
pwidth = font.getStringWidth("2x (1000x760)");
|
||||
items.clear();
|
||||
VarList::push_back(items, "Small", "small"); // 8x13
|
||||
VarList::push_back(items, "Low Medium", "low_medium"); // 9x15
|
||||
VarList::push_back(items, "Medium", "medium"); // 9x18
|
||||
VarList::push_back(items, "Large (10pt)", "large"); // 10x20
|
||||
VarList::push_back(items, "Large (12pt)", "large12"); // 12x24
|
||||
VarList::push_back(items, "Large (14pt)", "large14"); // 14x28
|
||||
VarList::push_back(items, "Large (16pt)", "large16"); // 16x32
|
||||
myLauncherFontPopup =
|
||||
new PopUpWidget(myTab, font, xpos, ypos + 1, pwidth, lineHeight, items,
|
||||
"Launcher font ", lwidth);
|
||||
wid.push_back(myLauncherFontPopup);
|
||||
// Track favorites
|
||||
ypos = myLauncherWidthSlider->getTop();
|
||||
myFavoritesWidget = new CheckboxWidget(myTab, _font, xpos2, ypos + 2,
|
||||
"Track favorites");
|
||||
myFavoritesWidget->setToolTip("Check to enable favorites tracking and display.");
|
||||
wid.push_back(myFavoritesWidget);
|
||||
ypos += lineHeight + VGAP;
|
||||
|
||||
// Display launcher extensions
|
||||
ypos += lineHeight + VGAP;
|
||||
myLauncherExtensionsWidget = new CheckboxWidget(myTab, _font, xpos, ypos + 1,
|
||||
myLauncherExtensionsWidget = new CheckboxWidget(myTab, _font, xpos2, ypos + 2,
|
||||
"Display file extensions");
|
||||
wid.push_back(myLauncherExtensionsWidget);
|
||||
|
||||
ypos += lineHeight + VGAP * 4;
|
||||
|
||||
// ROM launcher info/snapshot viewer
|
||||
ypos = myLauncherHeightSlider->getTop() + lineHeight + VGAP * 4;
|
||||
myRomViewerSize = new SliderWidget(myTab, font, xpos, ypos, "ROM info width ",
|
||||
lwidth, kRomViewer, 6 * fontWidth, "% ");
|
||||
myRomViewerSize->setMinValue(0);
|
||||
|
@ -359,6 +367,7 @@ void UIDialog::loadConfig()
|
|||
const string& launcherFont = settings.getString("launcherfont");
|
||||
myLauncherFontPopup->setSelected(launcherFont, "medium");
|
||||
|
||||
myFavoritesWidget->setState(settings.getBool("favorites"));
|
||||
myLauncherExtensionsWidget->setState(settings.getBool("launcherextensions"));
|
||||
|
||||
// ROM launcher info viewer
|
||||
|
@ -444,6 +453,8 @@ void UIDialog::saveConfig()
|
|||
settings.setValue("launcherfont",
|
||||
myLauncherFontPopup->getSelectedTag().toString());
|
||||
|
||||
// Track favorites
|
||||
settings.setValue("favorites", myFavoritesWidget->getState());
|
||||
// Display launcher extensions
|
||||
settings.setValue("launcherextensions", myLauncherExtensionsWidget->getState());
|
||||
|
||||
|
@ -530,6 +541,7 @@ void UIDialog::setDefaults()
|
|||
myLauncherWidthSlider->setValue(w);
|
||||
myLauncherHeightSlider->setValue(h);
|
||||
myLauncherFontPopup->setSelected("medium", "");
|
||||
myFavoritesWidget->setState(true);
|
||||
myLauncherExtensionsWidget->setState(false);
|
||||
myRomViewerSize->setValue(35);
|
||||
mySnapLoadPath->setText(instance().userDir().getShortPath());
|
||||
|
@ -551,12 +563,16 @@ void UIDialog::handleCommand(CommandSender* sender, int cmd, int data, int id)
|
|||
bool informPath = myIsGlobal &&
|
||||
(myRomPath->getText() != instance().settings().getString("romdir")
|
||||
|| myRomPath->getText() != instance().settings().getString("startromdir"));
|
||||
bool informFav = myIsGlobal &&
|
||||
myFavoritesWidget->getState() != instance().settings().getBool("favorites");
|
||||
bool informExt = myIsGlobal &&
|
||||
myLauncherExtensionsWidget->getState() != instance().settings().getBool("launcherextensions");
|
||||
saveConfig();
|
||||
close();
|
||||
if(informPath) // Let the boss know romdir has changed
|
||||
sendCommand(LauncherDialog::kRomDirChosenCmd, 0, 0);
|
||||
if(informFav) // Let the boss know the favaorites tracking has changed
|
||||
sendCommand(LauncherDialog::kFavChangedCmd, 0, 0);
|
||||
if(informExt) // Let the boss know the file extension display setting has changed
|
||||
sendCommand(LauncherDialog::kExtChangedCmd, 0, 0);
|
||||
break;
|
||||
|
|
|
@ -58,6 +58,7 @@ class UIDialog : public Dialog, public CommandSender
|
|||
SliderWidget* myLauncherHeightSlider{nullptr};
|
||||
PopUpWidget* myLauncherFontPopup{nullptr};
|
||||
CheckboxWidget* myLauncherExtensionsWidget{nullptr};
|
||||
CheckboxWidget* myFavoritesWidget{nullptr};
|
||||
SliderWidget* myRomViewerSize{nullptr};
|
||||
ButtonWidget* myOpenBrowserButton{nullptr};
|
||||
EditTextWidget* mySnapLoadPath{nullptr};
|
||||
|
|
Loading…
Reference in New Issue