From 93e81f180aecc4bdc8981ab92ccebe2e24ed1a3c Mon Sep 17 00:00:00 2001 From: thrust26 Date: Sun, 5 Apr 2020 21:30:38 +0200 Subject: [PATCH] remove new default path button replace with an UI option, which lets "romdir" automatically follow the launcher path --- src/emucore/Settings.cxx | 2 ++ src/gui/LauncherDialog.cxx | 52 ++++++++++++++++++-------------------- src/gui/LauncherDialog.hxx | 5 ++-- src/gui/UIDialog.cxx | 14 +++++++++- src/gui/UIDialog.hxx | 1 + 5 files changed, 42 insertions(+), 32 deletions(-) diff --git a/src/emucore/Settings.cxx b/src/emucore/Settings.cxx index a5bda6055..c3feece37 100644 --- a/src/emucore/Settings.cxx +++ b/src/emucore/Settings.cxx @@ -125,6 +125,7 @@ Settings::Settings() // ROM browser options setPermanent("exitlauncher", "false"); + setPermanent("followlauncher", "false"); setPermanent("launcherres", Common::Size(900, 600)); setPermanent("launcherfont", "medium"); setPermanent("launcherroms", "true"); @@ -500,6 +501,7 @@ void Settings::usage() const << " -launcherroms <1|0> Show only ROMs in the launcher (vs. all files)\n" << " -romviewer Show ROM info viewer at given zoom level in ROM\n" << " launcher (use 0 for off)\n" + << " -followlauncher <0|1> Default ROM path follows launcher navigation\n" << " -lastrom Last played ROM, automatically selected in\n" << " launcher\n" << " -romloadcount Number of ROM to load next from multicard\n" diff --git a/src/gui/LauncherDialog.cxx b/src/gui/LauncherDialog.cxx index 2e79307a8..fc47f9bbe 100644 --- a/src/gui/LauncherDialog.cxx +++ b/src/gui/LauncherDialog.cxx @@ -66,7 +66,7 @@ LauncherDialog::LauncherDialog(OSystem& osystem, DialogContainer& parent, const int fontWidth = font.getMaxCharWidth(), fontHeight = font.getFontHeight(), lineHeight = font.getLineHeight(), - bwidth = (_w - 2 * HBORDER - BUTTON_GAP * (5 - 1)), + bwidth = (_w - 2 * HBORDER - BUTTON_GAP * (4 - 1)), bheight = myUseMinimalUI ? lineHeight - 4 : lineHeight + 4, LBL_GAP = fontWidth; int xpos = 0, ypos = 0, lwidth = 0, lwidth2 = 0; @@ -176,50 +176,41 @@ LauncherDialog::LauncherDialog(OSystem& osystem, DialogContainer& parent, // Add four buttons at the bottom xpos = HBORDER; ypos += myDir->getHeight() + 8; #ifndef BSPF_MACOS - myStartButton = new ButtonWidget(this, font, xpos, ypos, (bwidth + 0) / 5, bheight, + myStartButton = new ButtonWidget(this, font, xpos, ypos, (bwidth + 0) / 4, bheight, "Select", kLoadROMCmd); wid.push_back(myStartButton); - xpos += (bwidth + 0) / 5 + BUTTON_GAP; - myPrevDirButton = new ButtonWidget(this, font, xpos, ypos, (bwidth + 1) / 5, bheight, + xpos += (bwidth + 0) / 4 + BUTTON_GAP; + myPrevDirButton = new ButtonWidget(this, font, xpos, ypos, (bwidth + 1) / 4, bheight, "Go Up", kPrevDirCmd); wid.push_back(myPrevDirButton); - xpos += (bwidth + 1) / 5 + BUTTON_GAP; - mySetDefaultDirButton = new ButtonWidget(this, font, xpos, ypos, (bwidth + 2) / 5, bheight, - "Set Path", kDefaultDirCmd); - wid.push_back(mySetDefaultDirButton); - - xpos += (bwidth + 2) / 5 + BUTTON_GAP; - myOptionsButton = new ButtonWidget(this, font, xpos, ypos, (bwidth + 3) / 5, bheight, + xpos += (bwidth + 1) / 4 + BUTTON_GAP; + myOptionsButton = new ButtonWidget(this, font, xpos, ypos, (bwidth + 3) / 4, bheight, "Options" + ELLIPSIS, kOptionsCmd); wid.push_back(myOptionsButton); - xpos += (bwidth + 3) / 5 + BUTTON_GAP; - myQuitButton = new ButtonWidget(this, font, xpos, ypos, (bwidth + 4) / 5, bheight, + xpos += (bwidth + 2) / 4 + BUTTON_GAP; + myQuitButton = new ButtonWidget(this, font, xpos, ypos, (bwidth + 4) / 4, bheight, "Quit", kQuitCmd); wid.push_back(myQuitButton); #else - myQuitButton = new ButtonWidget(this, font, xpos, ypos, (bwidth + 0) / 5, bheight, + myQuitButton = new ButtonWidget(this, font, xpos, ypos, (bwidth + 0) / 4, bheight, "Quit", kQuitCmd); wid.push_back(myQuitButton); - xpos += (bwidth + 0) / 5 + BUTTON_GAP; - myOptionsButton = new ButtonWidget(this, font, xpos, ypos, (bwidth + 1) / 5, bheight, + xpos += (bwidth + 0) / 4 + BUTTON_GAP; + myOptionsButton = new ButtonWidget(this, font, xpos, ypos, (bwidth + 1) / 4, bheight, "Options" + ELLIPSIS, kOptionsCmd); wid.push_back(myOptionsButton); - xpos += (bwidth + 1) / 5 + BUTTON_GAP; - mySetDefaultDirButton = new ButtonWidget(this, font, xpos, ypos, (bwidth + 2) / 5, bheight, - "Set Path", kDefaultDirCmd); - - xpos += (bwidth + 2) / 5 + BUTTON_GAP; - myPrevDirButton = new ButtonWidget(this, font, xpos, ypos, (bwidth + 3) / 5, bheight, + xpos += (bwidth + 1) / 4 + BUTTON_GAP; + myPrevDirButton = new ButtonWidget(this, font, xpos, ypos, (bwidth + 2) / 4, bheight, "Go Up", kPrevDirCmd); wid.push_back(myPrevDirButton); - xpos += (bwidth + 3) / 5 + BUTTON_GAP; - myStartButton = new ButtonWidget(this, font, xpos, ypos, (bwidth + 4) / 5, bheight, + xpos += (bwidth + 2) / 4 + BUTTON_GAP; + myStartButton = new ButtonWidget(this, font, xpos, ypos, (bwidth + 3) / 4, bheight, "Select", kLoadROMCmd); wid.push_back(myStartButton); #endif @@ -317,6 +308,13 @@ void LauncherDialog::loadConfig() myList->clearFlags(Widget::FLAG_WANTS_RAWDATA); // always reset this } +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +void LauncherDialog::saveConfig() +{ + if(instance().settings().getBool("followlauncher")) + instance().settings().setValue("romdir", myList->currentDir().getShortPath()); +} + // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void LauncherDialog::updateUI() { @@ -586,6 +584,7 @@ void LauncherDialog::handleCommand(CommandSender* sender, int cmd, case kLoadROMCmd: case FileListWidget::ItemActivated: + saveConfig(); loadRom(); break; @@ -597,10 +596,6 @@ void LauncherDialog::handleCommand(CommandSender* sender, int cmd, myList->selectParent(); break; - case kDefaultDirCmd: - setDefaultDir(); - break; - case FileListWidget::ItemChanged: updateUI(); break; @@ -617,6 +612,7 @@ void LauncherDialog::handleCommand(CommandSender* sender, int cmd, break; case kQuitCmd: + saveConfig(); close(); instance().eventHandler().quit(); break; diff --git a/src/gui/LauncherDialog.hxx b/src/gui/LauncherDialog.hxx index 6c03cd18d..dc1058356 100644 --- a/src/gui/LauncherDialog.hxx +++ b/src/gui/LauncherDialog.hxx @@ -107,6 +107,7 @@ class LauncherDialog : public Dialog Event::Type getJoyAxisEvent(int stick, JoyAxis axis, JoyDir adir, int button) override; void loadConfig() override; + void saveConfig() override; void updateUI(); void applyFiltering(); @@ -131,8 +132,7 @@ class LauncherDialog : public Dialog unique_ptr myROMInfoFont; ButtonWidget* myStartButton{nullptr}; - ButtonWidget* myPrevDirButton{nullptr}; - ButtonWidget* mySetDefaultDirButton{nullptr}; + ButtonWidget* myPrevDirButton{nullptr}; ButtonWidget* myOptionsButton{nullptr}; ButtonWidget* myQuitButton{nullptr}; @@ -155,7 +155,6 @@ class LauncherDialog : public Dialog enum { kAllfilesCmd = 'lalf', // show all files (or ROMs only) kPrevDirCmd = 'PRVD', - kDefaultDirCmd = 'DEFD', kOptionsCmd = 'OPTI', kQuitCmd = 'QUIT' }; diff --git a/src/gui/UIDialog.cxx b/src/gui/UIDialog.cxx index 175b8624b..fd52fa483 100644 --- a/src/gui/UIDialog.cxx +++ b/src/gui/UIDialog.cxx @@ -189,8 +189,14 @@ UIDialog::UIDialog(OSystem& osystem, DialogContainer& parent, myRomPath = new EditTextWidget(myTab, font, xpos, ypos + 1, _w - xpos - HBORDER - 2, lineHeight, ""); wid.push_back(myRomPath); + + xpos = _w - HBORDER - font.getStringWidth("Follow Launcher path") - 24; + ypos += lineHeight + V_GAP * 2; + myFollowLauncherWidget = new CheckboxWidget(myTab, font, xpos, ypos, "Follow Launcher path"); + wid.push_back(myFollowLauncherWidget); + xpos = HBORDER; - ypos += lineHeight + V_GAP * 4; + ypos += V_GAP * 2; // Launcher width and height myLauncherWidthSlider = new SliderWidget(myTab, font, xpos, ypos, "Launcher width ", @@ -309,6 +315,9 @@ void UIDialog::loadConfig() myLauncherWidthSlider->setValue(w); myLauncherHeightSlider->setValue(h); + // Follow Launcher path + myFollowLauncherWidget->setState(settings.getBool("followlauncher")); + // Launcher font const string& font = settings.getString("launcherfont"); myLauncherFontPopup->setSelected(font, "medium"); @@ -379,6 +388,9 @@ void UIDialog::saveConfig() // ROM path settings.setValue("romdir", myRomPath->getText()); + // Follow Launcher path + settings.setValue("followlauncher", myFollowLauncherWidget->getState()); + // Launcher size settings.setValue("launcherres", Common::Size(myLauncherWidthSlider->getValue(), diff --git a/src/gui/UIDialog.hxx b/src/gui/UIDialog.hxx index ff41c7702..4517396d0 100644 --- a/src/gui/UIDialog.hxx +++ b/src/gui/UIDialog.hxx @@ -54,6 +54,7 @@ class UIDialog : public Dialog, public CommandSender // Launcher options EditTextWidget* myRomPath{nullptr}; + CheckboxWidget* myFollowLauncherWidget{nullptr}; SliderWidget* myLauncherWidthSlider{nullptr}; SliderWidget* myLauncherHeightSlider{nullptr}; PopUpWidget* myLauncherFontPopup{nullptr};