added launcher directory history

This commit is contained in:
Thomas Jentzsch 2021-12-11 16:45:24 +01:00
parent 47e3bd5ffe
commit 81eba12884
9 changed files with 375 additions and 181 deletions

View File

@ -53,16 +53,25 @@ void FileListWidget::setDirectory(const FilesystemNode& node,
// Initialize history // Initialize history
FilesystemNode tmp = _node; FilesystemNode tmp = _node;
while(tmp.hasParent() && !_history.full()) string name = select;
_history.clear();
while(tmp.hasParent())
{ {
string name = tmp.getName();
if(name.back() == FilesystemNode::PATH_SEPARATOR) if(name.back() == FilesystemNode::PATH_SEPARATOR)
name.pop_back(); name.pop_back();
_history.push(name); _history.push_back(HistoryType(tmp, name));
name = tmp.getName();
if(name.back() == FilesystemNode::PATH_SEPARATOR)
name.pop_back();
tmp = tmp.getParent(); tmp = tmp.getParent();
} }
// History is in reverse order; we need to fix that // History is in reverse order; we need to fix that
_history.reverse(); std::reverse(_history.begin(), _history.end());
_currentHistory = std::prev(_history.end(), 1);
_historyHome = _currentHistory - _history.begin();
// Finally, go to this location // Finally, go to this location
setLocation(_node, _selectedFile); setLocation(_node, _selectedFile);
@ -70,8 +79,10 @@ void FileListWidget::setDirectory(const FilesystemNode& node,
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void FileListWidget::setLocation(const FilesystemNode& node, void FileListWidget::setLocation(const FilesystemNode& node,
const string& select) const string select)
{ {
cerr << node.getPath() << " : " << select << endl;
progress().resetProgress(); progress().resetProgress();
progress().open(); progress().open();
FilesystemNode::CancelCheck isCancelled = [this]() { FilesystemNode::CancelCheck isCancelled = [this]() {
@ -168,7 +179,7 @@ FileListWidget::IconType FileListWidget::getIconType(const string& path) const
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void FileListWidget::selectDirectory() void FileListWidget::selectDirectory()
{ {
_history.push(selected().getName()); addHistory(selected());
setLocation(selected(), _selectedFile); setLocation(selected(), _selectedFile);
} }
@ -176,7 +187,67 @@ void FileListWidget::selectDirectory()
void FileListWidget::selectParent() void FileListWidget::selectParent()
{ {
if(_node.hasParent()) if(_node.hasParent())
setLocation(_node.getParent(), !_history.empty() ? _history.pop() : EmptyString); {
string name = _node.getName();
FilesystemNode parent(_node.getParent());
if(name.back() == FilesystemNode::PATH_SEPARATOR)
name.pop_back();
_currentHistory->selected = selected().getName();
addHistory(parent);
setLocation(parent, name);
}
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void FileListWidget::selectPrevHistory()
{
if(_currentHistory != _history.begin() + _historyHome)
{
_currentHistory->selected = selected().getName();
_currentHistory = std::prev(_currentHistory, 1);
setLocation(_currentHistory->node, _currentHistory->selected);
}
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void FileListWidget::selectNextHistory()
{
if(_currentHistory != std::prev(_history.end(), 1))
{
_currentHistory->selected = selected().getName();
_currentHistory = std::next(_currentHistory, 1);
setLocation(_currentHistory->node, _currentHistory->selected);
}
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool FileListWidget::hasPrevHistory()
{
return _currentHistory != _history.begin() + _historyHome;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool FileListWidget::hasNextHistory()
{
return _currentHistory != std::prev(_history.end(), 1);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void FileListWidget::addHistory(const FilesystemNode& node)
{
//while(_history.size() > _historyIndex)
while(_currentHistory != std::prev(_history.end(), 1))
_history.pop_back();
string select = selected().getName();
if(select.back() == FilesystemNode::PATH_SEPARATOR)
select.pop_back();
_currentHistory->selected = select;
_history.push_back(HistoryType(node, select));
_currentHistory = std::prev(_history.end(), 1);
//_historyIndex++;
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -245,7 +316,7 @@ void FileListWidget::handleCommand(CommandSender* sender, int cmd, int data, int
{ {
switch (cmd) switch (cmd)
{ {
case ListWidget::kPrevDirCmd: case ListWidget::kParentDirCmd:
selectParent(); selectParent();
break; break;
@ -377,7 +448,7 @@ const FileListWidget::Icon* FileListWidget::getIcon(int i) const
0b11111000'00000000, 0b11111000'00000000,
0b11111100'00000000, 0b11111100'00000000,
0b11111111'11111110, 0b11111111'11111110,
0b10000000'00000010, 0b10000001'00000010,
0b10000011'10000010, 0b10000011'10000010,
0b10000111'11000010, 0b10000111'11000010,
0b10001111'11100010, 0b10001111'11100010,
@ -493,18 +564,18 @@ const FileListWidget::Icon* FileListWidget::getIcon(int i) const
0b11111111111'11111111110, 0b11111111111'11111111110,
0b11111111111'11111111110, 0b11111111111'11111111110,
0b11000000000'00000000110, 0b11000000000'00000000110,
0b11000000001'10000000110,
0b11000000011'10000000110, 0b11000000011'10000000110,
0b11000000111'11000000110, 0b11000000111'11000000110,
0b11000001111'11100000110, 0b11000001111'11100000110,
0b11000011111'11110000110, 0b11000011111'11110000110,
0b11000111111'11111000110, 0b11000111111'11111000110,
0b11001111111'11111100110, 0b11001111111'11111100110,
0b11001111111'11111100110, 0b11000000011'10000000110,
0b11000000111'11000000110, 0b11000000011'10000000110,
0b11000000111'11000000110, 0b11000000011'10000000110,
0b11000000111'11000000110, 0b11000000011'10000000110,
0b11000000111'11000000110, 0b11000000011'10000000110,
0b11000000111'11000000110,
0b11000000000'00000000110, 0b11000000000'00000000110,
0b11111111111'11111111110, 0b11111111111'11111111110,
0b11111111111'11111111110 0b11111111111'11111111110

View File

@ -79,10 +79,18 @@ class FileListWidget : public StringListWidget
void setDirectory(const FilesystemNode& node, void setDirectory(const FilesystemNode& node,
const string& select = EmptyString); const string& select = EmptyString);
/** Select parent directory (if applicable) */
void selectParent();
/** Descend into currently selected directory */ /** Descend into currently selected directory */
virtual void selectDirectory(); virtual void selectDirectory();
/** Select parent directory (if applicable) */
void selectParent();
/** Select previous directory in history (if applicable) */
void selectPrevHistory();
/** Select next directory in history */
void selectNextHistory();
/** Check if the there is a previous directory in history */
bool hasPrevHistory();
/** Check if the there is a next directory in history */
bool hasNextHistory();
/** Reload current location (file or directory) */ /** Reload current location (file or directory) */
void reload(); void reload();
@ -101,6 +109,16 @@ class FileListWidget : public StringListWidget
void incProgress(); void incProgress();
protected: protected:
struct HistoryType
{
FilesystemNode node;
string selected;
HistoryType()
: node{}, selected{} {}
explicit HistoryType(const FilesystemNode _node, const string _selected)
: node{_node}, selected{_selected} {}
};
enum class IconType { enum class IconType {
unknown, unknown,
rom, rom,
@ -121,7 +139,7 @@ class FileListWidget : public StringListWidget
protected: protected:
/** Very similar to setDirectory(), but also updates the history */ /** Very similar to setDirectory(), but also updates the history */
void setLocation(const FilesystemNode& node, const string& select); void setLocation(const FilesystemNode& node, const string select);
virtual bool isDirectory(const FilesystemNode& node) const; virtual bool isDirectory(const FilesystemNode& node) const;
virtual void getChildren(const FilesystemNode::CancelCheck& isCancelled); virtual void getChildren(const FilesystemNode::CancelCheck& isCancelled);
virtual void extendLists(StringList& list) { } virtual void extendLists(StringList& list) { }
@ -129,14 +147,17 @@ class FileListWidget : public StringListWidget
virtual const Icon* getIcon(int i) const; virtual const Icon* getIcon(int i) const;
int iconWidth() const; int iconWidth() const;
virtual bool fullPathToolTip() const { return false; } virtual bool fullPathToolTip() const { return false; }
void addHistory(const FilesystemNode& node);
protected: protected:
FilesystemNode _node; FilesystemNode _node;
FSList _fileList; FSList _fileList;
FilesystemNode::NameFilter _filter; FilesystemNode::NameFilter _filter;
Common::FixedStack<string> _history;
string _selectedFile; string _selectedFile;
StringList _dirList; StringList _dirList;
std::vector<HistoryType> _history;
int _historyHome{0}; // offset into initially created history
std::vector<HistoryType>::iterator _currentHistory{_history.begin()};
IconTypeList _iconTypeList; IconTypeList _iconTypeList;
private: private:

View File

@ -60,13 +60,53 @@ static const Icon icon_up_small(
0b00011111111100, 0b00011111111100,
0b00111111111110, 0b00111111111110,
0b01111111111111, 0b01111111111111,
0b00000111110000, 0b00000011100000,
0b00000111110000, 0b00000011100000,
0b00000111110000, 0b00000011100000,
0b00000111110000, 0b00000011100000,
0b00000111110000, 0b00000011100000,
0b00000111110000, 0b00000011100000,
0b00000111110000 0b00000011100000
});
// Previous icon
static const Icon icon_prev_small(
iconSmallDesc,
{
0b00000000000000,
0b00000010000000,
0b00000110000000,
0b00001110000000,
0b00011110000000,
0b00111110000000,
0b01111111111111,
0b11111111111111,
0b01111111111111,
0b00111110000000,
0b00011110000000,
0b00001110000000,
0b00000110000000,
0b00000010000000
});
// Next icon
static const Icon icon_next_small(
iconSmallDesc,
{
0b00000000000000,
0b00000001000000,
0b00000001100000,
0b00000001110000,
0b00000001111000,
0b00000001111100,
0b11111111111110,
0b11111111111111,
0b11111111111110,
0b00000001111100,
0b00000001111000,
0b00000001110000,
0b00000001100000,
0b00000001000000
}); });
// Home icon // Home icon
@ -210,6 +250,7 @@ static const Icon icon_settings_large(
0b0001111111111111000, 0b0001111111111111000,
0b0000111000001110000 0b0000111000001110000
}); });
// Up icon // Up icon
static const Icon icon_up_large( static const Icon icon_up_large(
iconLargeDesc, iconLargeDesc,
@ -224,16 +265,68 @@ static const Icon icon_up_large(
0b0011111111111111100, 0b0011111111111111100,
0b0111111111111111110, 0b0111111111111111110,
0b1111111111111111111, 0b1111111111111111111,
0b0000001111111000000, 0b0000000111110000000,
0b0000001111111000000, 0b0000000111110000000,
0b0000001111111000000, 0b0000000111110000000,
0b0000001111111000000, 0b0000000111110000000,
0b0000001111111000000, 0b0000000111110000000,
0b0000001111111000000, 0b0000000111110000000,
0b0000001111111000000, 0b0000000111110000000,
0b0000001111111000000, 0b0000000111110000000,
0b0000001111111000000, 0b0000000111110000000,
0b0000001111111000000 0b0000000111110000000
});
// Previous icon
static const Icon icon_prev_large(
iconLargeDesc,
{
0b0000000000000000000,
0b0000000001000000000,
0b0000000011000000000,
0b0000000111000000000,
0b0000001111000000000,
0b0000011111000000000,
0b0000111111000000000,
0b0001111111000000000,
0b0011111111111111111,
0b0111111111111111111,
0b1111111111111111111,
0b0111111111111111111,
0b0011111111111111111,
0b0001111111000000000,
0b0000111111000000000,
0b0000011111000000000,
0b0000001111000000000,
0b0000000111000000000,
0b0000000011000000000,
0b0000000001000000000
});
// Next icon
static const Icon icon_next_large(
iconLargeDesc,
{
0b0000000000000000000,
0b0000000001000000000,
0b0000000001100000000,
0b0000000001110000000,
0b0000000001111000000,
0b0000000001111100000,
0b0000000001111110000,
0b0000000001111111000,
0b1111111111111111100,
0b1111111111111111110,
0b1111111111111111111,
0b1111111111111111110,
0b1111111111111111100,
0b0000000001111111000,
0b0000000001111110000,
0b0000000001111100000,
0b0000000001111000000,
0b0000000001110000000,
0b0000000001100000000,
0b0000000001000000000
}); });
// Home icon // Home icon

View File

@ -65,7 +65,8 @@
LauncherDialog::LauncherDialog(OSystem& osystem, DialogContainer& parent, LauncherDialog::LauncherDialog(OSystem& osystem, DialogContainer& parent,
int x, int y, int w, int h) int x, int y, int w, int h)
: Dialog(osystem, parent, osystem.frameBuffer().launcherFont(), "", : Dialog(osystem, parent, osystem.frameBuffer().launcherFont(), "",
x, y, w, h) x, y, w, h),
CommandSender(this)
{ {
const bool bottomButtons = instance().settings().getBool("launcherbuttons"); const bool bottomButtons = instance().settings().getBool("launcherbuttons");
int ypos = Dialog::vBorder(); int ypos = Dialog::vBorder();
@ -84,7 +85,7 @@ LauncherDialog::LauncherDialog(OSystem& osystem, DialogContainer& parent,
if(myUseMinimalUI) // Highlight 'Rom Listing' if(myUseMinimalUI) // Highlight 'Rom Listing'
mySelectedItem = 0; // skip nothing mySelectedItem = 0; // skip nothing
else else
mySelectedItem = 7; // skip filter items and 3 navigation buttons mySelectedItem = 9; // skip filter items and 5 navigation buttons
addToFocusList(wid); addToFocusList(wid);
@ -215,30 +216,42 @@ void LauncherDialog::addPathWidgets(int& ypos, WidgetArray& wid)
const int iconGap = (fontWidth + 1) & ~0b1; // round up to next even const int iconGap = (fontWidth + 1) & ~0b1; // round up to next even
const string lblFound = "12345 items"; const string lblFound = "12345 items";
const int lwFound = _font.getStringWidth(lblFound); const int lwFound = _font.getStringWidth(lblFound);
const GUI::Icon& reloadIcon = smallIcon ? GUI::icon_reload_small : GUI::icon_reload_large;
const int iconWidth = reloadIcon.width();
int xpos = HBORDER; int xpos = HBORDER;
if(!myUseMinimalUI) if(!myUseMinimalUI)
{ {
const GUI::Icon& prevIcon = smallIcon ? GUI::icon_prev_small : GUI::icon_prev_large;
const GUI::Icon& nextIcon = smallIcon ? GUI::icon_next_small : GUI::icon_next_large;
const GUI::Icon& homeIcon = smallIcon ? GUI::icon_home_small : GUI::icon_home_large; const GUI::Icon& homeIcon = smallIcon ? GUI::icon_home_small : GUI::icon_home_large;
const GUI::Icon& upIcon = smallIcon ? GUI::icon_up_small : GUI::icon_up_large; const GUI::Icon& upIcon = smallIcon ? GUI::icon_up_small : GUI::icon_up_large;
const int iconWidth = homeIcon.width();
myHomeButton = new ButtonWidget(this, _font, xpos, ypos, myHomeButton = new ButtonWidget(this, _font, xpos, ypos,
iconWidth + iconGap - 1, lineHeight + 2, homeIcon, kHomeDirCmd); iconWidth + iconGap - 1, lineHeight + 2, homeIcon, kHomeDirCmd);
myHomeButton->setToolTip("Go back to Stella's ROM directory."); myHomeButton->setToolTip("Go back to Stella's ROM directory.");
wid.push_back(myHomeButton); wid.push_back(myHomeButton);
xpos = myHomeButton->getRight() + BTN_GAP; xpos = myHomeButton->getRight() + BTN_GAP;
myPrevButton = new ButtonWidget(this, _font, xpos, ypos,
iconWidth + iconGap - 1, lineHeight + 2, prevIcon, kPrevDirCmd);
myPrevButton->setToolTip("Go back in directory history.");
wid.push_back(myPrevButton);
xpos = myPrevButton->getRight() + BTN_GAP;
myNextButton = new ButtonWidget(this, _font, xpos, ypos,
iconWidth + iconGap - 1, lineHeight + 2, nextIcon, kNextDirCmd);
myNextButton->setToolTip("Go forward in directory history.");
wid.push_back(myNextButton);
xpos = myNextButton->getRight() + BTN_GAP;
myUpButton = new ButtonWidget(this, _font, xpos, ypos, myUpButton = new ButtonWidget(this, _font, xpos, ypos,
iconWidth + iconGap - 1, lineHeight + 2, upIcon, kPrevDirCmd); iconWidth + iconGap - 1, lineHeight + 2, upIcon, kParentDirCmd);
myUpButton->setToolTip("Go Up"); myUpButton->setToolTip("Go Up");
wid.push_back(myUpButton); wid.push_back(myUpButton);
xpos = myUpButton->getRight() + BTN_GAP; xpos = myUpButton->getRight() + BTN_GAP;
} }
const GUI::Icon& reloadIcon = smallIcon ? GUI::icon_reload_small : GUI::icon_reload_large;
const int iconWidth = reloadIcon.width();
myDir = new EditTextWidget(this, _font, xpos, ypos, myDir = new EditTextWidget(this, _font, xpos, ypos,
_w - xpos - (myUseMinimalUI _w - xpos - (myUseMinimalUI
? lwFound + LBL_GAP ? lwFound + LBL_GAP
@ -344,9 +357,9 @@ void LauncherDialog::addButtonWidgets(int& ypos, WidgetArray& wid)
wid.push_back(myStartButton); wid.push_back(myStartButton);
xpos += (buttonWidth + 0) / 4 + BUTTON_GAP; xpos += (buttonWidth + 0) / 4 + BUTTON_GAP;
myPrevDirButton = new ButtonWidget(this, _font, xpos, ypos, (buttonWidth + 1) / 4, buttonHeight, myGoUpButton = new ButtonWidget(this, _font, xpos, ypos, (buttonWidth + 1) / 4, buttonHeight,
"Go Up", kPrevDirCmd); "Go Up", kParentDirCmd);
wid.push_back(myPrevDirButton); wid.push_back(myGoUpButton);
xpos += (buttonWidth + 1) / 4 + BUTTON_GAP; xpos += (buttonWidth + 1) / 4 + BUTTON_GAP;
myOptionsButton = new ButtonWidget(this, _font, xpos, ypos, (buttonWidth + 3) / 4, buttonHeight, myOptionsButton = new ButtonWidget(this, _font, xpos, ypos, (buttonWidth + 3) / 4, buttonHeight,
@ -368,9 +381,9 @@ void LauncherDialog::addButtonWidgets(int& ypos, WidgetArray& wid)
wid.push_back(myOptionsButton); wid.push_back(myOptionsButton);
xpos += (buttonWidth + 1) / 4 + BUTTON_GAP; xpos += (buttonWidth + 1) / 4 + BUTTON_GAP;
myPrevDirButton = new ButtonWidget(this, _font, xpos, ypos, (buttonWidth + 2) / 4, buttonHeight, myGoUpButton = new ButtonWidget(this, _font, xpos, ypos, (buttonWidth + 2) / 4, buttonHeight,
"Go Up", kPrevDirCmd); "Go Up", kParentDirCmd);
wid.push_back(myPrevDirButton); wid.push_back(myGoUpButton);
xpos += (buttonWidth + 2) / 4 + BUTTON_GAP; xpos += (buttonWidth + 2) / 4 + BUTTON_GAP;
myStartButton = new ButtonWidget(this, _font, xpos, ypos, (buttonWidth + 3) / 4, buttonHeight, myStartButton = new ButtonWidget(this, _font, xpos, ypos, (buttonWidth + 3) / 4, buttonHeight,
@ -505,9 +518,18 @@ void LauncherDialog::saveConfig()
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void LauncherDialog::updateUI() void LauncherDialog::updateUI()
{ {
// Only hilite the 'up' button if there's a parent directory // Only enable the 'up' button if there's a parent directory
if(myPrevDirButton) if(myGoUpButton)
myPrevDirButton->setEnabled(myList->currentDir().hasParent()); myGoUpButton->setEnabled(myList->currentDir().hasParent());
// Only enable the navigation buttons if function is available
if(myHomeButton)
myHomeButton->setEnabled(myList->hasPrevHistory());
if(myPrevButton)
myPrevButton->setEnabled(myList->hasPrevHistory());
if(myNextButton)
myNextButton->setEnabled(myList->hasNextHistory());
if(myUpButton)
myUpButton->setEnabled(myList->currentDir().hasParent());
// Show current directory // Show current directory
myDir->setText(myList->currentDir().getShortPath()); myDir->setText(myList->currentDir().getShortPath());
@ -735,11 +757,11 @@ void LauncherDialog::handleContextMenu()
myList->removeFavorite(); myList->removeFavorite();
reload(); reload();
} }
else if (cmd == "removefavorites") else if(cmd == "removefavorites")
removeAllFavorites(); removeAllFavorites();
else if (cmd == "removepopular") else if(cmd == "removepopular")
removeAllPopular(); removeAllPopular();
else if (cmd == "removerecent") else if(cmd == "removerecent")
removeAllRecent(); removeAllRecent();
else if(cmd == "override") else if(cmd == "override")
openGlobalProps(); openGlobalProps();
@ -748,13 +770,11 @@ void LauncherDialog::handleContextMenu()
else if(cmd == "sorting") else if(cmd == "sorting")
toggleSorting(); toggleSorting();
else if(cmd == "showall") else if(cmd == "showall")
toggleShowAll(); sendCommand(kAllfilesCmd, 0, 0);
else if(cmd == "subdirs") else if(cmd == "subdirs")
toggleSubDirs(); sendCommand(kSubDirsCmd, 0, 0);
else if(cmd == "homedir") else if(cmd == "homedir")
gotoHomeDir(); sendCommand(kHomeDirCmd, 0, 0);
else if(cmd == "prevdir")
myList->selectParent();
else if(cmd == "highscores") else if(cmd == "highscores")
openHighScores(); openHighScores();
else if(cmd == "reload") else if(cmd == "reload")
@ -789,58 +809,91 @@ void LauncherDialog::handleKeyDown(StellaKey key, StellaMod mod, bool repeated)
// context menu keys // context menu keys
bool handled = false; bool handled = false;
if(StellaModTest::isControl(mod) && if(!(myPattern->isHighlighted()
!(myPattern->isHighlighted() && instance().eventHandler().eventForKey(EventMode::kEditMode, key, mod) != Event::NoType))
&& instance().eventHandler().eventForKey(EventMode::kEditMode, key, mod) != Event::NoType))
{ {
handled = true; if(StellaModTest::isAlt(mod))
switch(key)
{ {
case KBDK_A: handled = true;
toggleShowAll(); switch(key)
break; {
case KBDK_HOME:
sendCommand(kHomeDirCmd, 0, 0);
break;
case KBDK_D: case KBDK_LEFT:
toggleSubDirs(); sendCommand(kPrevDirCmd, 0, 0);
break; break;
case KBDK_E: case KBDK_RIGHT:
toggleExtensions(); sendCommand(kNextDirCmd, 0, 0);
break; break;
case KBDK_F: case KBDK_UP:
myList->toggleUserFavorite(); sendCommand(kParentDirCmd, 0, 0);
break; break;
case KBDK_H: case KBDK_DOWN:
if(instance().highScores().enabled()) sendCommand(kLoadROMCmd, 0, 0);
openHighScores(); break;
break;
case KBDK_O: default:
openSettings(); handled = false;
break; break;
}
}
else if(StellaModTest::isControl(mod))
{
handled = true;
switch(key)
{
case KBDK_A:
sendCommand(kAllfilesCmd, 0, 0);
toggleShowAll();
break;
case KBDK_P: case KBDK_D:
openGlobalProps(); sendCommand(kSubDirsCmd, 0, 0);
break; break;
case KBDK_R: case KBDK_E:
reload(); toggleExtensions();
break; break;
case KBDK_S: case KBDK_F:
toggleSorting(); myList->toggleUserFavorite();
break; break;
case KBDK_X: case KBDK_H:
myList->removeFavorite(); if(instance().highScores().enabled())
reload(); openHighScores();
break; break;
default: case KBDK_O:
handled = false; openSettings();
break; break;
case KBDK_P:
openGlobalProps();
break;
case KBDK_R:
reload();
break;
case KBDK_S:
toggleSorting();
break;
case KBDK_X:
myList->removeFavorite();
reload();
break;
default:
handled = false;
break;
}
} }
} }
if(!handled) if(!handled)
@ -849,8 +902,7 @@ void LauncherDialog::handleKeyDown(StellaKey key, StellaMod mod, bool repeated)
switch(key) switch(key)
{ {
case KBDK_F8: // front ("Skill P2") case KBDK_F8: // front ("Skill P2")
if (!currentNode().isDirectory() && Bankswitch::isValidRomName(currentNode())) openGlobalProps();
openGlobalProps();
break; break;
case KBDK_F4: // back ("COLOR", "B/W") case KBDK_F4: // back ("COLOR", "B/W")
openSettings(); openSettings();
@ -890,8 +942,7 @@ void LauncherDialog::handleJoyUp(int stick, int button)
// open power-up options and settings for 2nd and 4th button if not mapped otherwise // open power-up options and settings for 2nd and 4th button if not mapped otherwise
Event::Type e = instance().eventHandler().eventForJoyButton(EventMode::kMenuMode, stick, button); Event::Type e = instance().eventHandler().eventForJoyButton(EventMode::kMenuMode, stick, button);
if (button == 1 && (e == Event::UIOK || e == Event::NoType) && if (button == 1 && (e == Event::UIOK || e == Event::NoType))
!currentNode().isDirectory() && Bankswitch::isValidRomName(currentNode()))
openGlobalProps(); openGlobalProps();
if (button == 3 && (e == Event::UITabPrev || e == Event::NoType)) if (button == 3 && (e == Event::UITabPrev || e == Event::NoType))
openSettings(); openSettings();
@ -960,6 +1011,19 @@ void LauncherDialog::handleCommand(CommandSender* sender, int cmd,
gotoHomeDir(); gotoHomeDir();
break; break;
case kPrevDirCmd:
myList->selectPrevHistory();
break;
case kNextDirCmd:
myList->selectNextHistory();
break;
case kParentDirCmd:
myList->selectParent();
break;
case kLoadROMCmd: case kLoadROMCmd:
if(myList->isDirectory(myList->selected())) if(myList->isDirectory(myList->selected()))
{ {
@ -978,10 +1042,6 @@ void LauncherDialog::handleCommand(CommandSender* sender, int cmd,
openSettings(); openSettings();
break; break;
case kPrevDirCmd:
myList->selectParent();
break;
case kReloadCmd: case kReloadCmd:
reload(); reload();
break; break;
@ -1227,12 +1287,15 @@ void LauncherDialog::openSettings()
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void LauncherDialog::openGlobalProps() void LauncherDialog::openGlobalProps()
{ {
// Create global props dialog, which is used to temporarily override if(!currentNode().isDirectory() && Bankswitch::isValidRomName(currentNode()))
// ROM properties {
myDialog = make_unique<GlobalPropsDialog>(this, myUseMinimalUI // Create global props dialog, which is used to temporarily override
? _font // ROM properties
: instance().frameBuffer().font()); myDialog = make_unique<GlobalPropsDialog>(this, myUseMinimalUI
myDialog->open(); ? _font
: instance().frameBuffer().font());
myDialog->open();
}
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -1254,16 +1317,8 @@ void LauncherDialog::openWhatsNew()
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void LauncherDialog::gotoHomeDir() void LauncherDialog::gotoHomeDir()
{ {
if(myList->currentDir().getPath() != instance().settings().getString("startromdir")) while(myList->hasPrevHistory())
{ myList->selectPrevHistory();
FilesystemNode node(instance().settings().getString("startromdir"));
if(!myList->isDirectory(node))
node = FilesystemNode("~");
myList->setDirectory(node);
reload();
}
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

View File

@ -44,7 +44,7 @@ namespace GUI {
#include "FSNode.hxx" #include "FSNode.hxx"
#include "Variant.hxx" #include "Variant.hxx"
class LauncherDialog : public Dialog class LauncherDialog : public Dialog, CommandSender
{ {
public: public:
// These must be accessible from dialogs created by this class // These must be accessible from dialogs created by this class
@ -201,6 +201,8 @@ class LauncherDialog : public Dialog
StaticTextWidget* myRomCount{nullptr}; StaticTextWidget* myRomCount{nullptr};
ButtonWidget* myHomeButton{nullptr}; ButtonWidget* myHomeButton{nullptr};
ButtonWidget* myPrevButton{nullptr};
ButtonWidget* myNextButton{nullptr};
ButtonWidget* myUpButton{nullptr}; ButtonWidget* myUpButton{nullptr};
EditTextWidget* myDir{nullptr}; EditTextWidget* myDir{nullptr};
ButtonWidget* myReloadButton{nullptr}; ButtonWidget* myReloadButton{nullptr};
@ -208,7 +210,7 @@ class LauncherDialog : public Dialog
LauncherFileListWidget* myList{nullptr}; LauncherFileListWidget* myList{nullptr};
ButtonWidget* myStartButton{nullptr}; ButtonWidget* myStartButton{nullptr};
ButtonWidget* myPrevDirButton{nullptr}; ButtonWidget* myGoUpButton{nullptr};
ButtonWidget* myOptionsButton{nullptr}; ButtonWidget* myOptionsButton{nullptr};
ButtonWidget* myQuitButton{nullptr}; ButtonWidget* myQuitButton{nullptr};
@ -232,10 +234,12 @@ class LauncherDialog : public Dialog
enum { enum {
kAllfilesCmd = 'lalf', // show all files (or ROMs only) kAllfilesCmd = 'lalf', // show all files (or ROMs only)
kSubDirsCmd = 'lred', kSubDirsCmd = 'lred',
kPrevDirCmd = 'PRVD', kParentDirCmd = 'PARD',
kOptionsCmd = 'OPTI', kOptionsCmd = 'OPTI',
kQuitCmd = 'QUIT', kQuitCmd = 'QUIT',
kHomeDirCmd = 'homc', // goto Home directory kHomeDirCmd = 'homc', // go to Home directory
kPrevDirCmd = 'prvc', // go back in history to previous directory
kNextDirCmd = 'nxtc', // go back in history to next directory
kReloadCmd = 'relc', kReloadCmd = 'relc',
kRmAllFav = 'rmaf', kRmAllFav = 'rmaf',
kRmAllPop = 'rmap', kRmAllPop = 'rmap',

View File

@ -34,15 +34,6 @@ LauncherFileListWidget::LauncherFileListWidget(GuiObject* boss, const GUI::Font&
myRomDir = startRomDir(); myRomDir = startRomDir();
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void LauncherFileListWidget::selectDirectory()
{
if(!myInVirtualDir && !_history.empty())
_history.pop();
_history.push(selected().getName());
setLocation(selected(), _selectedFile);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool LauncherFileListWidget::isDirectory(const FilesystemNode& node) const bool LauncherFileListWidget::isDirectory(const FilesystemNode& node) const
{ {
@ -274,21 +265,6 @@ FileListWidget::IconType LauncherFileListWidget::getIconType(const string& path)
const FileListWidget::Icon* LauncherFileListWidget::getIcon(int i) const const FileListWidget::Icon* LauncherFileListWidget::getIcon(int i) const
{ {
static const Icon favrom_small = { static const Icon favrom_small = {
//0b00000011'00000000,
//0b00000111'10000000,
//0b00000100'10000000,
//0b00001100'11000000,
//0b01111000'01111000,
//0b11000000'00001100,
//0b01100000'00011000,
//0b00110000'00110000,
//0b00011000'01100000,
//0b00110000'00110000,
//0b00100011'00010000,
//0b01101111'11011000,
//0b01111000'01111000,
//0b00110000'00110000
0b00000000'00001000, 0b00000000'00001000,
0b00001111'00011100, 0b00001111'00011100,
0b00001010'01111111, 0b00001010'01111111,
@ -386,29 +362,6 @@ const FileListWidget::Icon* LauncherFileListWidget::getIcon(int i) const
}; };
static const Icon favrom_large = { static const Icon favrom_large = {
//0b00000000000'00000000000,
//0b00000000001'00000000000,
//0b00000000011'10000000000,
//0b00000000011'10000000000,
//0b00000000111'11000000000,
//0b00000000111'11000000000,
//0b00000000110'11000000000,
//0b00000001100'01100000000,
//0b01111111100'01111111100,
//0b11111111000'00111111110,
//0b01110000000'00000011100,
//0b00111000000'00000111000,
//0b00011100000'00001110000,
//0b00001110000'00011100000,
//0b00000111000'00111000000,
//0b00001110000'00011100000,
//0b00001110011'10011100000,
//0b00011100111'11001110000,
//0b00011001110'11100110000,
//0b00111111000'00111111000,
//0b00111110000'00011111000,
//0b00011000000'00000110000
0b00000000000'00000100000, 0b00000000000'00000100000,
0b00000011111'11101110000, 0b00000011111'11101110000,
0b00000011111'11001110000, 0b00000011111'11001110000,

View File

@ -39,9 +39,6 @@ class LauncherFileListWidget : public FileListWidget
int x, int y, int w, int h); int x, int y, int w, int h);
~LauncherFileListWidget() override = default; ~LauncherFileListWidget() override = default;
/** Descend into currently selected directory */
void selectDirectory() override;
void loadFavorites(); void loadFavorites();
void saveFavorites(bool force = false); void saveFavorites(bool force = false);
void clearFavorites(); void clearFavorites();

View File

@ -374,7 +374,7 @@ bool ListWidget::handleEvent(Event::Type e)
break; break;
case Event::UIPrevDir: case Event::UIPrevDir:
sendCommand(ListWidget::kPrevDirCmd, _selectedItem, _id); sendCommand(ListWidget::kParentDirCmd, _selectedItem, _id);
break; break;
default: default:

View File

@ -37,7 +37,7 @@ class ListWidget : public EditableWidget
kRClickedCmd = 'LIrc', // right click on item - 'data' will be item index kRClickedCmd = 'LIrc', // right click on item - 'data' will be item index
kSelectionChangedCmd = 'Lsch', // selection changed - 'data' will be item index kSelectionChangedCmd = 'Lsch', // selection changed - 'data' will be item index
kScrolledCmd = 'Lscl', // list scrolled - 'data' will be current position kScrolledCmd = 'Lscl', // list scrolled - 'data' will be current position
kPrevDirCmd = 'Lpdr' // request to go to parent list, if applicable kParentDirCmd = 'Lpdr' // request to go to parent list, if applicable
}; };
public: public: