mirror of https://github.com/stella-emu/stella.git
added launcher directory history
This commit is contained in:
parent
f999bd685a
commit
64e5b1362b
|
@ -53,16 +53,25 @@ void FileListWidget::setDirectory(const FilesystemNode& node,
|
|||
|
||||
// Initialize history
|
||||
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)
|
||||
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();
|
||||
}
|
||||
// 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
|
||||
setLocation(_node, _selectedFile);
|
||||
|
@ -70,8 +79,10 @@ void FileListWidget::setDirectory(const FilesystemNode& node,
|
|||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void FileListWidget::setLocation(const FilesystemNode& node,
|
||||
const string& select)
|
||||
const string select)
|
||||
{
|
||||
cerr << node.getPath() << " : " << select << endl;
|
||||
|
||||
progress().resetProgress();
|
||||
progress().open();
|
||||
FilesystemNode::CancelCheck isCancelled = [this]() {
|
||||
|
@ -168,7 +179,7 @@ FileListWidget::IconType FileListWidget::getIconType(const string& path) const
|
|||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void FileListWidget::selectDirectory()
|
||||
{
|
||||
_history.push(selected().getName());
|
||||
addHistory(selected());
|
||||
setLocation(selected(), _selectedFile);
|
||||
}
|
||||
|
||||
|
@ -176,7 +187,67 @@ void FileListWidget::selectDirectory()
|
|||
void FileListWidget::selectParent()
|
||||
{
|
||||
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)
|
||||
{
|
||||
case ListWidget::kPrevDirCmd:
|
||||
case ListWidget::kParentDirCmd:
|
||||
selectParent();
|
||||
break;
|
||||
|
||||
|
@ -377,7 +448,7 @@ const FileListWidget::Icon* FileListWidget::getIcon(int i) const
|
|||
0b11111000'00000000,
|
||||
0b11111100'00000000,
|
||||
0b11111111'11111110,
|
||||
0b10000000'00000010,
|
||||
0b10000001'00000010,
|
||||
0b10000011'10000010,
|
||||
0b10000111'11000010,
|
||||
0b10001111'11100010,
|
||||
|
@ -493,18 +564,18 @@ const FileListWidget::Icon* FileListWidget::getIcon(int i) const
|
|||
0b11111111111'11111111110,
|
||||
0b11111111111'11111111110,
|
||||
0b11000000000'00000000110,
|
||||
0b11000000001'10000000110,
|
||||
0b11000000011'10000000110,
|
||||
0b11000000111'11000000110,
|
||||
0b11000001111'11100000110,
|
||||
0b11000011111'11110000110,
|
||||
0b11000111111'11111000110,
|
||||
0b11001111111'11111100110,
|
||||
0b11001111111'11111100110,
|
||||
0b11000000111'11000000110,
|
||||
0b11000000111'11000000110,
|
||||
0b11000000111'11000000110,
|
||||
0b11000000111'11000000110,
|
||||
0b11000000111'11000000110,
|
||||
0b11000000011'10000000110,
|
||||
0b11000000011'10000000110,
|
||||
0b11000000011'10000000110,
|
||||
0b11000000011'10000000110,
|
||||
0b11000000011'10000000110,
|
||||
0b11000000000'00000000110,
|
||||
0b11111111111'11111111110,
|
||||
0b11111111111'11111111110
|
||||
|
|
|
@ -79,10 +79,18 @@ class FileListWidget : public StringListWidget
|
|||
void setDirectory(const FilesystemNode& node,
|
||||
const string& select = EmptyString);
|
||||
|
||||
/** Select parent directory (if applicable) */
|
||||
void selectParent();
|
||||
/** Descend into currently selected directory */
|
||||
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) */
|
||||
void reload();
|
||||
|
@ -101,6 +109,16 @@ class FileListWidget : public StringListWidget
|
|||
void incProgress();
|
||||
|
||||
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 {
|
||||
unknown,
|
||||
rom,
|
||||
|
@ -121,7 +139,7 @@ class FileListWidget : public StringListWidget
|
|||
|
||||
protected:
|
||||
/** 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 void getChildren(const FilesystemNode::CancelCheck& isCancelled);
|
||||
virtual void extendLists(StringList& list) { }
|
||||
|
@ -129,14 +147,17 @@ class FileListWidget : public StringListWidget
|
|||
virtual const Icon* getIcon(int i) const;
|
||||
int iconWidth() const;
|
||||
virtual bool fullPathToolTip() const { return false; }
|
||||
void addHistory(const FilesystemNode& node);
|
||||
|
||||
protected:
|
||||
FilesystemNode _node;
|
||||
FSList _fileList;
|
||||
FilesystemNode::NameFilter _filter;
|
||||
Common::FixedStack<string> _history;
|
||||
string _selectedFile;
|
||||
StringList _dirList;
|
||||
std::vector<HistoryType> _history;
|
||||
int _historyHome{0}; // offset into initially created history
|
||||
std::vector<HistoryType>::iterator _currentHistory{_history.begin()};
|
||||
IconTypeList _iconTypeList;
|
||||
|
||||
private:
|
||||
|
|
|
@ -60,13 +60,53 @@ static const Icon icon_up_small(
|
|||
0b00011111111100,
|
||||
0b00111111111110,
|
||||
0b01111111111111,
|
||||
0b00000111110000,
|
||||
0b00000111110000,
|
||||
0b00000111110000,
|
||||
0b00000111110000,
|
||||
0b00000111110000,
|
||||
0b00000111110000,
|
||||
0b00000111110000
|
||||
0b00000011100000,
|
||||
0b00000011100000,
|
||||
0b00000011100000,
|
||||
0b00000011100000,
|
||||
0b00000011100000,
|
||||
0b00000011100000,
|
||||
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
|
||||
|
@ -210,6 +250,7 @@ static const Icon icon_settings_large(
|
|||
0b0001111111111111000,
|
||||
0b0000111000001110000
|
||||
});
|
||||
|
||||
// Up icon
|
||||
static const Icon icon_up_large(
|
||||
iconLargeDesc,
|
||||
|
@ -224,16 +265,68 @@ static const Icon icon_up_large(
|
|||
0b0011111111111111100,
|
||||
0b0111111111111111110,
|
||||
0b1111111111111111111,
|
||||
0b0000001111111000000,
|
||||
0b0000001111111000000,
|
||||
0b0000001111111000000,
|
||||
0b0000001111111000000,
|
||||
0b0000001111111000000,
|
||||
0b0000001111111000000,
|
||||
0b0000001111111000000,
|
||||
0b0000001111111000000,
|
||||
0b0000001111111000000,
|
||||
0b0000001111111000000
|
||||
0b0000000111110000000,
|
||||
0b0000000111110000000,
|
||||
0b0000000111110000000,
|
||||
0b0000000111110000000,
|
||||
0b0000000111110000000,
|
||||
0b0000000111110000000,
|
||||
0b0000000111110000000,
|
||||
0b0000000111110000000,
|
||||
0b0000000111110000000,
|
||||
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
|
||||
|
|
|
@ -65,7 +65,8 @@
|
|||
LauncherDialog::LauncherDialog(OSystem& osystem, DialogContainer& parent,
|
||||
int x, int y, int w, int h)
|
||||
: Dialog(osystem, parent, osystem.frameBuffer().launcherFont(), "",
|
||||
x, y, w, h)
|
||||
x, y, w, h),
|
||||
CommandSender(this)
|
||||
{
|
||||
const bool bottomButtons = instance().settings().getBool("launcherbuttons");
|
||||
int ypos = Dialog::vBorder();
|
||||
|
@ -84,7 +85,7 @@ LauncherDialog::LauncherDialog(OSystem& osystem, DialogContainer& parent,
|
|||
if(myUseMinimalUI) // Highlight 'Rom Listing'
|
||||
mySelectedItem = 0; // skip nothing
|
||||
else
|
||||
mySelectedItem = 7; // skip filter items and 3 navigation buttons
|
||||
mySelectedItem = 9; // skip filter items and 5 navigation buttons
|
||||
|
||||
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 string lblFound = "12345 items";
|
||||
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;
|
||||
|
||||
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& upIcon = smallIcon ? GUI::icon_up_small : GUI::icon_up_large;
|
||||
const int iconWidth = homeIcon.width();
|
||||
|
||||
myHomeButton = new ButtonWidget(this, _font, xpos, ypos,
|
||||
iconWidth + iconGap - 1, lineHeight + 2, homeIcon, kHomeDirCmd);
|
||||
myHomeButton->setToolTip("Go back to Stella's ROM directory.");
|
||||
wid.push_back(myHomeButton);
|
||||
|
||||
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,
|
||||
iconWidth + iconGap - 1, lineHeight + 2, upIcon, kPrevDirCmd);
|
||||
iconWidth + iconGap - 1, lineHeight + 2, upIcon, kParentDirCmd);
|
||||
myUpButton->setToolTip("Go Up");
|
||||
wid.push_back(myUpButton);
|
||||
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,
|
||||
_w - xpos - (myUseMinimalUI
|
||||
? lwFound + LBL_GAP
|
||||
|
@ -344,9 +357,9 @@ void LauncherDialog::addButtonWidgets(int& ypos, WidgetArray& wid)
|
|||
wid.push_back(myStartButton);
|
||||
|
||||
xpos += (buttonWidth + 0) / 4 + BUTTON_GAP;
|
||||
myPrevDirButton = new ButtonWidget(this, _font, xpos, ypos, (buttonWidth + 1) / 4, buttonHeight,
|
||||
"Go Up", kPrevDirCmd);
|
||||
wid.push_back(myPrevDirButton);
|
||||
myGoUpButton = new ButtonWidget(this, _font, xpos, ypos, (buttonWidth + 1) / 4, buttonHeight,
|
||||
"Go Up", kParentDirCmd);
|
||||
wid.push_back(myGoUpButton);
|
||||
|
||||
xpos += (buttonWidth + 1) / 4 + BUTTON_GAP;
|
||||
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);
|
||||
|
||||
xpos += (buttonWidth + 1) / 4 + BUTTON_GAP;
|
||||
myPrevDirButton = new ButtonWidget(this, _font, xpos, ypos, (buttonWidth + 2) / 4, buttonHeight,
|
||||
"Go Up", kPrevDirCmd);
|
||||
wid.push_back(myPrevDirButton);
|
||||
myGoUpButton = new ButtonWidget(this, _font, xpos, ypos, (buttonWidth + 2) / 4, buttonHeight,
|
||||
"Go Up", kParentDirCmd);
|
||||
wid.push_back(myGoUpButton);
|
||||
|
||||
xpos += (buttonWidth + 2) / 4 + BUTTON_GAP;
|
||||
myStartButton = new ButtonWidget(this, _font, xpos, ypos, (buttonWidth + 3) / 4, buttonHeight,
|
||||
|
@ -505,9 +518,18 @@ void LauncherDialog::saveConfig()
|
|||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void LauncherDialog::updateUI()
|
||||
{
|
||||
// Only hilite the 'up' button if there's a parent directory
|
||||
if(myPrevDirButton)
|
||||
myPrevDirButton->setEnabled(myList->currentDir().hasParent());
|
||||
// Only enable the 'up' button if there's a parent directory
|
||||
if(myGoUpButton)
|
||||
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
|
||||
myDir->setText(myList->currentDir().getShortPath());
|
||||
|
@ -735,11 +757,11 @@ void LauncherDialog::handleContextMenu()
|
|||
myList->removeFavorite();
|
||||
reload();
|
||||
}
|
||||
else if (cmd == "removefavorites")
|
||||
else if(cmd == "removefavorites")
|
||||
removeAllFavorites();
|
||||
else if (cmd == "removepopular")
|
||||
else if(cmd == "removepopular")
|
||||
removeAllPopular();
|
||||
else if (cmd == "removerecent")
|
||||
else if(cmd == "removerecent")
|
||||
removeAllRecent();
|
||||
else if(cmd == "override")
|
||||
openGlobalProps();
|
||||
|
@ -748,13 +770,11 @@ void LauncherDialog::handleContextMenu()
|
|||
else if(cmd == "sorting")
|
||||
toggleSorting();
|
||||
else if(cmd == "showall")
|
||||
toggleShowAll();
|
||||
sendCommand(kAllfilesCmd, 0, 0);
|
||||
else if(cmd == "subdirs")
|
||||
toggleSubDirs();
|
||||
sendCommand(kSubDirsCmd, 0, 0);
|
||||
else if(cmd == "homedir")
|
||||
gotoHomeDir();
|
||||
else if(cmd == "prevdir")
|
||||
myList->selectParent();
|
||||
sendCommand(kHomeDirCmd, 0, 0);
|
||||
else if(cmd == "highscores")
|
||||
openHighScores();
|
||||
else if(cmd == "reload")
|
||||
|
@ -789,58 +809,91 @@ void LauncherDialog::handleKeyDown(StellaKey key, StellaMod mod, bool repeated)
|
|||
// context menu keys
|
||||
bool handled = false;
|
||||
|
||||
if(StellaModTest::isControl(mod) &&
|
||||
!(myPattern->isHighlighted()
|
||||
&& instance().eventHandler().eventForKey(EventMode::kEditMode, key, mod) != Event::NoType))
|
||||
if(!(myPattern->isHighlighted()
|
||||
&& instance().eventHandler().eventForKey(EventMode::kEditMode, key, mod) != Event::NoType))
|
||||
{
|
||||
handled = true;
|
||||
switch(key)
|
||||
if(StellaModTest::isAlt(mod))
|
||||
{
|
||||
case KBDK_A:
|
||||
toggleShowAll();
|
||||
break;
|
||||
handled = true;
|
||||
switch(key)
|
||||
{
|
||||
case KBDK_HOME:
|
||||
sendCommand(kHomeDirCmd, 0, 0);
|
||||
break;
|
||||
|
||||
case KBDK_D:
|
||||
toggleSubDirs();
|
||||
break;
|
||||
case KBDK_LEFT:
|
||||
sendCommand(kPrevDirCmd, 0, 0);
|
||||
break;
|
||||
|
||||
case KBDK_E:
|
||||
toggleExtensions();
|
||||
break;
|
||||
case KBDK_RIGHT:
|
||||
sendCommand(kNextDirCmd, 0, 0);
|
||||
break;
|
||||
|
||||
case KBDK_F:
|
||||
myList->toggleUserFavorite();
|
||||
break;
|
||||
case KBDK_UP:
|
||||
sendCommand(kParentDirCmd, 0, 0);
|
||||
break;
|
||||
|
||||
case KBDK_H:
|
||||
if(instance().highScores().enabled())
|
||||
openHighScores();
|
||||
break;
|
||||
case KBDK_DOWN:
|
||||
sendCommand(kLoadROMCmd, 0, 0);
|
||||
break;
|
||||
|
||||
case KBDK_O:
|
||||
openSettings();
|
||||
break;
|
||||
default:
|
||||
handled = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if(StellaModTest::isControl(mod))
|
||||
{
|
||||
handled = true;
|
||||
switch(key)
|
||||
{
|
||||
case KBDK_A:
|
||||
sendCommand(kAllfilesCmd, 0, 0);
|
||||
toggleShowAll();
|
||||
break;
|
||||
|
||||
case KBDK_P:
|
||||
openGlobalProps();
|
||||
break;
|
||||
case KBDK_D:
|
||||
sendCommand(kSubDirsCmd, 0, 0);
|
||||
break;
|
||||
|
||||
case KBDK_R:
|
||||
reload();
|
||||
break;
|
||||
case KBDK_E:
|
||||
toggleExtensions();
|
||||
break;
|
||||
|
||||
case KBDK_S:
|
||||
toggleSorting();
|
||||
break;
|
||||
case KBDK_F:
|
||||
myList->toggleUserFavorite();
|
||||
break;
|
||||
|
||||
case KBDK_X:
|
||||
myList->removeFavorite();
|
||||
reload();
|
||||
break;
|
||||
case KBDK_H:
|
||||
if(instance().highScores().enabled())
|
||||
openHighScores();
|
||||
break;
|
||||
|
||||
default:
|
||||
handled = false;
|
||||
break;
|
||||
case KBDK_O:
|
||||
openSettings();
|
||||
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)
|
||||
|
@ -849,8 +902,7 @@ void LauncherDialog::handleKeyDown(StellaKey key, StellaMod mod, bool repeated)
|
|||
switch(key)
|
||||
{
|
||||
case KBDK_F8: // front ("Skill P2")
|
||||
if (!currentNode().isDirectory() && Bankswitch::isValidRomName(currentNode()))
|
||||
openGlobalProps();
|
||||
openGlobalProps();
|
||||
break;
|
||||
case KBDK_F4: // back ("COLOR", "B/W")
|
||||
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
|
||||
Event::Type e = instance().eventHandler().eventForJoyButton(EventMode::kMenuMode, stick, button);
|
||||
|
||||
if (button == 1 && (e == Event::UIOK || e == Event::NoType) &&
|
||||
!currentNode().isDirectory() && Bankswitch::isValidRomName(currentNode()))
|
||||
if (button == 1 && (e == Event::UIOK || e == Event::NoType))
|
||||
openGlobalProps();
|
||||
if (button == 3 && (e == Event::UITabPrev || e == Event::NoType))
|
||||
openSettings();
|
||||
|
@ -960,6 +1011,19 @@ void LauncherDialog::handleCommand(CommandSender* sender, int cmd,
|
|||
gotoHomeDir();
|
||||
break;
|
||||
|
||||
case kPrevDirCmd:
|
||||
myList->selectPrevHistory();
|
||||
break;
|
||||
|
||||
case kNextDirCmd:
|
||||
myList->selectNextHistory();
|
||||
break;
|
||||
|
||||
case kParentDirCmd:
|
||||
myList->selectParent();
|
||||
break;
|
||||
|
||||
|
||||
case kLoadROMCmd:
|
||||
if(myList->isDirectory(myList->selected()))
|
||||
{
|
||||
|
@ -978,10 +1042,6 @@ void LauncherDialog::handleCommand(CommandSender* sender, int cmd,
|
|||
openSettings();
|
||||
break;
|
||||
|
||||
case kPrevDirCmd:
|
||||
myList->selectParent();
|
||||
break;
|
||||
|
||||
case kReloadCmd:
|
||||
reload();
|
||||
break;
|
||||
|
@ -1227,12 +1287,15 @@ void LauncherDialog::openSettings()
|
|||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void LauncherDialog::openGlobalProps()
|
||||
{
|
||||
// Create global props dialog, which is used to temporarily override
|
||||
// ROM properties
|
||||
myDialog = make_unique<GlobalPropsDialog>(this, myUseMinimalUI
|
||||
? _font
|
||||
: instance().frameBuffer().font());
|
||||
myDialog->open();
|
||||
if(!currentNode().isDirectory() && Bankswitch::isValidRomName(currentNode()))
|
||||
{
|
||||
// Create global props dialog, which is used to temporarily override
|
||||
// ROM properties
|
||||
myDialog = make_unique<GlobalPropsDialog>(this, myUseMinimalUI
|
||||
? _font
|
||||
: instance().frameBuffer().font());
|
||||
myDialog->open();
|
||||
}
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
@ -1254,16 +1317,8 @@ void LauncherDialog::openWhatsNew()
|
|||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void LauncherDialog::gotoHomeDir()
|
||||
{
|
||||
if(myList->currentDir().getPath() != instance().settings().getString("startromdir"))
|
||||
{
|
||||
FilesystemNode node(instance().settings().getString("startromdir"));
|
||||
|
||||
if(!myList->isDirectory(node))
|
||||
node = FilesystemNode("~");
|
||||
|
||||
myList->setDirectory(node);
|
||||
reload();
|
||||
}
|
||||
while(myList->hasPrevHistory())
|
||||
myList->selectPrevHistory();
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
|
|
@ -44,7 +44,7 @@ namespace GUI {
|
|||
#include "FSNode.hxx"
|
||||
#include "Variant.hxx"
|
||||
|
||||
class LauncherDialog : public Dialog
|
||||
class LauncherDialog : public Dialog, CommandSender
|
||||
{
|
||||
public:
|
||||
// These must be accessible from dialogs created by this class
|
||||
|
@ -201,6 +201,8 @@ class LauncherDialog : public Dialog
|
|||
StaticTextWidget* myRomCount{nullptr};
|
||||
|
||||
ButtonWidget* myHomeButton{nullptr};
|
||||
ButtonWidget* myPrevButton{nullptr};
|
||||
ButtonWidget* myNextButton{nullptr};
|
||||
ButtonWidget* myUpButton{nullptr};
|
||||
EditTextWidget* myDir{nullptr};
|
||||
ButtonWidget* myReloadButton{nullptr};
|
||||
|
@ -208,7 +210,7 @@ class LauncherDialog : public Dialog
|
|||
LauncherFileListWidget* myList{nullptr};
|
||||
|
||||
ButtonWidget* myStartButton{nullptr};
|
||||
ButtonWidget* myPrevDirButton{nullptr};
|
||||
ButtonWidget* myGoUpButton{nullptr};
|
||||
ButtonWidget* myOptionsButton{nullptr};
|
||||
ButtonWidget* myQuitButton{nullptr};
|
||||
|
||||
|
@ -232,10 +234,12 @@ class LauncherDialog : public Dialog
|
|||
enum {
|
||||
kAllfilesCmd = 'lalf', // show all files (or ROMs only)
|
||||
kSubDirsCmd = 'lred',
|
||||
kPrevDirCmd = 'PRVD',
|
||||
kParentDirCmd = 'PARD',
|
||||
kOptionsCmd = 'OPTI',
|
||||
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',
|
||||
kRmAllFav = 'rmaf',
|
||||
kRmAllPop = 'rmap',
|
||||
|
|
|
@ -34,15 +34,6 @@ LauncherFileListWidget::LauncherFileListWidget(GuiObject* boss, const GUI::Font&
|
|||
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
|
||||
{
|
||||
|
@ -274,21 +265,6 @@ FileListWidget::IconType LauncherFileListWidget::getIconType(const string& path)
|
|||
const FileListWidget::Icon* LauncherFileListWidget::getIcon(int i) const
|
||||
{
|
||||
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,
|
||||
0b00001111'00011100,
|
||||
0b00001010'01111111,
|
||||
|
@ -386,29 +362,6 @@ const FileListWidget::Icon* LauncherFileListWidget::getIcon(int i) const
|
|||
};
|
||||
|
||||
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,
|
||||
0b00000011111'11101110000,
|
||||
0b00000011111'11001110000,
|
||||
|
|
|
@ -39,9 +39,6 @@ class LauncherFileListWidget : public FileListWidget
|
|||
int x, int y, int w, int h);
|
||||
~LauncherFileListWidget() override = default;
|
||||
|
||||
/** Descend into currently selected directory */
|
||||
void selectDirectory() override;
|
||||
|
||||
void loadFavorites();
|
||||
void saveFavorites(bool force = false);
|
||||
void clearFavorites();
|
||||
|
|
|
@ -374,7 +374,7 @@ bool ListWidget::handleEvent(Event::Type e)
|
|||
break;
|
||||
|
||||
case Event::UIPrevDir:
|
||||
sendCommand(ListWidget::kPrevDirCmd, _selectedItem, _id);
|
||||
sendCommand(ListWidget::kParentDirCmd, _selectedItem, _id);
|
||||
break;
|
||||
|
||||
default:
|
||||
|
|
|
@ -37,7 +37,7 @@ class ListWidget : public EditableWidget
|
|||
kRClickedCmd = 'LIrc', // right click on item - 'data' will be item index
|
||||
kSelectionChangedCmd = 'Lsch', // selection changed - 'data' will be item index
|
||||
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:
|
||||
|
|
Loading…
Reference in New Issue