mirror of https://github.com/stella-emu/stella.git
added file browser button for bezel selection
This commit is contained in:
parent
5642b4ff56
commit
cf20011628
|
@ -75,15 +75,15 @@ BrowserDialog::BrowserDialog(GuiObject* boss, const GUI::Font& font,
|
|||
buttonWidth, buttonHeight, "Go up", kGoUpCmd);
|
||||
addFocusWidget(_goUpButton);
|
||||
|
||||
b = new ButtonWidget(this, font, _goUpButton->getRight() + BUTTON_GAP, _h - buttonHeight - VBORDER,
|
||||
_baseDirButton = new ButtonWidget(this, font, _goUpButton->getRight() + BUTTON_GAP, _h - buttonHeight - VBORDER,
|
||||
buttonWidth, buttonHeight, "Base Dir", kBaseDirCmd);
|
||||
b->setToolTip("Go to Stella's base directory.");
|
||||
addFocusWidget(b);
|
||||
_baseDirButton->setToolTip("Go to Stella's base directory.");
|
||||
addFocusWidget(_baseDirButton);
|
||||
|
||||
b = new ButtonWidget(this, font, b->getRight() + BUTTON_GAP, _h - buttonHeight - VBORDER,
|
||||
_homeDirButton = new ButtonWidget(this, font, _baseDirButton->getRight() + BUTTON_GAP, _h - buttonHeight - VBORDER,
|
||||
buttonWidth, buttonHeight, "Home Dir", kHomeDirCmd);
|
||||
b->setToolTip("Go to user's home directory.");
|
||||
addFocusWidget(b);
|
||||
_homeDirButton->setToolTip("Go to user's home directory.");
|
||||
addFocusWidget(_homeDirButton);
|
||||
|
||||
#ifndef BSPF_MACOS
|
||||
b = new ButtonWidget(this, font, _w - (2 * buttonWidth + BUTTON_GAP + HBORDER), _h - buttonHeight - VBORDER,
|
||||
|
@ -174,6 +174,17 @@ void BrowserDialog::show(string_view startpath,
|
|||
directory = fs.isDirectory() ? "" : fs.getParent().getPath();
|
||||
}
|
||||
|
||||
// Default navigation settings:
|
||||
_navigationBar->setVisible(true);
|
||||
_fileList->setListMode(FSNode::ListMode::All);
|
||||
_fileList->setShowFileExtensions(true);
|
||||
_goUpButton->clearFlags(Widget::FLAG_INVISIBLE);
|
||||
_goUpButton->setEnabled(true);
|
||||
_baseDirButton->clearFlags(Widget::FLAG_INVISIBLE);
|
||||
_baseDirButton->setEnabled(true);
|
||||
_homeDirButton->clearFlags(Widget::FLAG_INVISIBLE);
|
||||
_homeDirButton->setEnabled(true);
|
||||
|
||||
switch(_mode)
|
||||
{
|
||||
case Mode::FileLoad:
|
||||
|
@ -193,6 +204,32 @@ void BrowserDialog::show(string_view startpath,
|
|||
_okWidget->setLabel("Load");
|
||||
break;
|
||||
|
||||
case Mode::FileLoadNoDirs:
|
||||
_fileList->setListMode(FSNode::ListMode::FilesOnly);
|
||||
_fileList->setNameFilter(namefilter);
|
||||
_fileList->setHeight(_selected->getTop() - VGAP * 2 - _fileList->getTop());
|
||||
_fileList->setShowFileExtensions(false);
|
||||
|
||||
_navigationBar->setVisible(false);
|
||||
_navigationBar->setEnabled(false);
|
||||
// Hide "save" checkbox
|
||||
//_navigationBar->setWidth(_savePathBox->getRight() - _navigationBar->getLeft());
|
||||
_savePathBox->setEnabled(false);
|
||||
_savePathBox->setFlags(Widget::FLAG_INVISIBLE);
|
||||
|
||||
_name->clearFlags(Widget::FLAG_INVISIBLE);
|
||||
_selected->clearFlags(Widget::FLAG_INVISIBLE);
|
||||
_selected->setEditable(false);
|
||||
_selected->setEnabled(false);
|
||||
_goUpButton->setFlags(Widget::FLAG_INVISIBLE);
|
||||
_goUpButton->setEnabled(false);
|
||||
_baseDirButton->setFlags(Widget::FLAG_INVISIBLE);
|
||||
_baseDirButton->setEnabled(false);
|
||||
_homeDirButton->setFlags(Widget::FLAG_INVISIBLE);
|
||||
_homeDirButton->setEnabled(false);
|
||||
_okWidget->setLabel("Select");
|
||||
break;
|
||||
|
||||
case Mode::FileSave:
|
||||
_fileList->setListMode(FSNode::ListMode::All);
|
||||
_fileList->setNameFilter(namefilter);
|
||||
|
@ -240,12 +277,13 @@ void BrowserDialog::show(string_view startpath,
|
|||
|
||||
// Finally, open the dialog after it has been fully updated
|
||||
open();
|
||||
setFocus(_fileList);
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
const FSNode& BrowserDialog::getResult() const
|
||||
{
|
||||
if(_mode == Mode::FileLoad || _mode == Mode::FileSave)
|
||||
if(_mode != Mode::Directories)
|
||||
{
|
||||
static FSNode node;
|
||||
|
||||
|
@ -324,7 +362,8 @@ void BrowserDialog::handleCommand(CommandSender* sender, int cmd,
|
|||
void BrowserDialog::updateUI(bool fileSelected)
|
||||
{
|
||||
// Only hilite the 'up' button if there's a parent directory
|
||||
_goUpButton->setEnabled(_fileList->currentDir().hasParent());
|
||||
_goUpButton->setEnabled(_goUpButton->isVisible()
|
||||
&& _fileList->currentDir().hasParent());
|
||||
|
||||
// Update the path display
|
||||
_navigationBar->updateUI();
|
||||
|
|
|
@ -35,6 +35,7 @@ class BrowserDialog : public Dialog
|
|||
public:
|
||||
enum class Mode {
|
||||
FileLoad, // File selector, no input from user
|
||||
FileLoadNoDirs, // File selector, no input from user, fixed directory
|
||||
FileSave, // File selector, filename changable by user
|
||||
Directories // Directories only, no input from user
|
||||
};
|
||||
|
@ -125,6 +126,8 @@ class BrowserDialog : public Dialog
|
|||
StaticTextWidget* _name{nullptr};
|
||||
EditTextWidget* _selected{nullptr};
|
||||
ButtonWidget* _goUpButton{nullptr};
|
||||
ButtonWidget* _baseDirButton{nullptr};
|
||||
ButtonWidget* _homeDirButton{nullptr};
|
||||
CheckboxWidget* _savePathBox{nullptr};
|
||||
|
||||
BrowserDialog::Mode _mode{Mode::Directories};
|
||||
|
|
|
@ -473,21 +473,28 @@ void GameInfoDialog::addCartridgeTab()
|
|||
wid.push_back(myNote);
|
||||
|
||||
ypos += lineHeight + VGAP;
|
||||
int bw = buttonWidth(">");
|
||||
new StaticTextWidget(myTab, _font, xpos, ypos + 1, lwidth, fontHeight, "Link");
|
||||
myUrl = new EditTextWidget(myTab, _font, xpos + lwidth, ypos - 1,
|
||||
fwidth - buttonWidth(">>") - HGAP, lineHeight, "");
|
||||
fwidth - bw - HGAP, lineHeight, "");
|
||||
myUrl->setID(kLinkId);
|
||||
myUrlButton = new ButtonWidget(myTab, _font, _w - HBORDER - 2 - buttonWidth(">>"), ypos - 1,
|
||||
buttonWidth(">>"), myUrl->getHeight(), ">>", kLinkPressed);
|
||||
wid.push_back(myUrl);
|
||||
|
||||
myUrlButton = new ButtonWidget(myTab, _font, _w - HBORDER - 2 - bw, ypos - 1,
|
||||
bw, myUrl->getHeight(), ">>", kLinkPressed);
|
||||
wid.push_back(myUrlButton);
|
||||
|
||||
ypos += lineHeight + VGAP;
|
||||
new StaticTextWidget(myTab, _font, xpos, ypos + 1, lwidth, fontHeight, "Bezelname");
|
||||
myBezelName = new EditTextWidget(myTab, _font, xpos + lwidth, ypos - 1,
|
||||
fwidth, lineHeight, "");
|
||||
fwidth - bw - HGAP, lineHeight, "");
|
||||
myBezelName->setToolTip("Define the name of the bezel file.");
|
||||
wid.push_back(myBezelName);
|
||||
|
||||
myBezelButton = new ButtonWidget(myTab, _font, _w - HBORDER - 2 - bw, ypos - 1,
|
||||
bw, myBezelName->getHeight(), ELLIPSIS, kBezelFilePressed);
|
||||
wid.push_back(myBezelButton);
|
||||
|
||||
// Add items for tab 3
|
||||
addToFocusList(wid, myTab, tabID);
|
||||
|
||||
|
@ -1578,6 +1585,19 @@ void GameInfoDialog::handleCommand(CommandSender* sender, int cmd,
|
|||
MediaFactory::openURL(myUrl->getText());
|
||||
break;
|
||||
|
||||
case kBezelFilePressed:
|
||||
BrowserDialog::show(this, _font, "Select bezel image",
|
||||
instance().bezelDir().getPath() + myBezelName->getText(),
|
||||
BrowserDialog::Mode::FileLoadNoDirs,
|
||||
[this](bool OK, const FSNode& node) {
|
||||
if(OK)
|
||||
myBezelName->setText(node.getNameWithExt(""));
|
||||
},
|
||||
[](const FSNode& node) {
|
||||
return BSPF::endsWithIgnoreCase(node.getName(), ".png");
|
||||
});
|
||||
break;
|
||||
|
||||
case EditTextWidget::kChangedCmd:
|
||||
if(id == kLinkId)
|
||||
{
|
||||
|
|
|
@ -137,9 +137,10 @@ class GameInfoDialog : public Dialog, public CommandSender
|
|||
EditTextWidget* myModelNo{nullptr};
|
||||
EditTextWidget* myRarity{nullptr};
|
||||
EditTextWidget* myNote{nullptr};
|
||||
ButtonWidget* myUrlButton{nullptr};
|
||||
EditTextWidget* myUrl{nullptr};
|
||||
ButtonWidget* myUrlButton{nullptr};
|
||||
EditTextWidget* myBezelName{nullptr};
|
||||
ButtonWidget* myBezelButton{nullptr};
|
||||
|
||||
// High Scores properties
|
||||
CheckboxWidget* myHighScores{nullptr};
|
||||
|
@ -193,7 +194,8 @@ class GameInfoDialog : public Dialog, public CommandSender
|
|||
kPXCenterChanged = 'Pxch',
|
||||
kPYCenterChanged = 'Pych',
|
||||
kExportPressed = 'Expr',
|
||||
kLinkPressed = 'Lkpr'
|
||||
kLinkPressed = 'Lkpr',
|
||||
kBezelFilePressed = 'BFpr'
|
||||
};
|
||||
|
||||
enum { kLinkId };
|
||||
|
|
|
@ -108,8 +108,47 @@ void NavigationWidget::setWidth(int w)
|
|||
Widget::setWidth(w);
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void NavigationWidget::setVisible(bool isVisible)
|
||||
{
|
||||
if(isVisible)
|
||||
{
|
||||
this->clearFlags(FLAG_INVISIBLE);
|
||||
this->setEnabled(true);
|
||||
myHomeButton->clearFlags(FLAG_INVISIBLE);
|
||||
myHomeButton->setEnabled(true);
|
||||
myPrevButton->clearFlags(FLAG_INVISIBLE);
|
||||
myHomeButton->setEnabled(true);
|
||||
myNextButton->clearFlags(FLAG_INVISIBLE);
|
||||
myHomeButton->setEnabled(true);
|
||||
myUpButton->clearFlags(FLAG_INVISIBLE);
|
||||
myHomeButton->setEnabled(true);
|
||||
myPath->clearFlags(FLAG_INVISIBLE);
|
||||
myPath->setEnabled(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
this->setFlags(FLAG_INVISIBLE);
|
||||
this->setEnabled(false);
|
||||
myHomeButton->setFlags(FLAG_INVISIBLE);
|
||||
myHomeButton->setEnabled(false);
|
||||
myPrevButton->setFlags(FLAG_INVISIBLE);
|
||||
myPrevButton->setEnabled(false);
|
||||
myNextButton->setFlags(FLAG_INVISIBLE);
|
||||
myNextButton->setEnabled(false);
|
||||
myUpButton->setFlags(FLAG_INVISIBLE);
|
||||
myUpButton->setEnabled(false);
|
||||
|
||||
myPath->setFlags(FLAG_INVISIBLE);
|
||||
myPath->setEnabled(false);
|
||||
myPath->setPath("");
|
||||
}
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void NavigationWidget::updateUI()
|
||||
{
|
||||
if(isVisible())
|
||||
{
|
||||
// Only enable the navigation buttons if function is available
|
||||
if(myUseMinimalUI)
|
||||
|
@ -125,6 +164,7 @@ void NavigationWidget::updateUI()
|
|||
myPath->setPath(myList->currentDir().getShortPath());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void NavigationWidget::handleCommand(CommandSender* sender, int cmd, int data,
|
||||
|
|
|
@ -91,6 +91,7 @@ class NavigationWidget : public Widget
|
|||
|
||||
void setWidth(int w) override;
|
||||
void setList(FileListWidget* list);
|
||||
void setVisible(bool isVisible);
|
||||
void updateUI();
|
||||
|
||||
private:
|
||||
|
|
Loading…
Reference in New Issue