mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2024-11-27 00:25:38 +00:00
Hooked up the "INPUT" button on scraper searches.
This commit is contained in:
parent
9fe7ceeb72
commit
b4f5577bd5
|
@ -11,6 +11,7 @@
|
||||||
#include "../Settings.h"
|
#include "../Settings.h"
|
||||||
#include "../Log.h"
|
#include "../Log.h"
|
||||||
#include "../Util.h"
|
#include "../Util.h"
|
||||||
|
#include "../guis/GuiTextEditPopup.h"
|
||||||
|
|
||||||
ScraperSearchComponent::ScraperSearchComponent(Window* window, SearchType type) : GuiComponent(window),
|
ScraperSearchComponent::ScraperSearchComponent(Window* window, SearchType type) : GuiComponent(window),
|
||||||
mGrid(window, Eigen::Vector2i(4, 3)),
|
mGrid(window, Eigen::Vector2i(4, 3)),
|
||||||
|
@ -161,6 +162,14 @@ void ScraperSearchComponent::search(const ScraperSearchParams& params)
|
||||||
mSearchHandle = Settings::getInstance()->getScraper()->getResultsAsync(params);
|
mSearchHandle = Settings::getInstance()->getScraper()->getResultsAsync(params);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ScraperSearchComponent::stop()
|
||||||
|
{
|
||||||
|
mThumbnailReq.reset();
|
||||||
|
mSearchHandle.reset();
|
||||||
|
mMDResolveHandle.reset();
|
||||||
|
mBlockAccept = false;
|
||||||
|
}
|
||||||
|
|
||||||
void ScraperSearchComponent::onSearchDone(const std::vector<ScraperSearchResult>& results)
|
void ScraperSearchComponent::onSearchDone(const std::vector<ScraperSearchResult>& results)
|
||||||
{
|
{
|
||||||
mResultList->clear();
|
mResultList->clear();
|
||||||
|
@ -365,6 +374,21 @@ void ScraperSearchComponent::updateThumbnail()
|
||||||
mGrid.onSizeChanged(); // a hack to fix the thumbnail position since its size changed
|
mGrid.onSizeChanged(); // a hack to fix the thumbnail position since its size changed
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ScraperSearchComponent::openInputScreen(ScraperSearchParams& params)
|
||||||
|
{
|
||||||
|
auto searchForFunc = [&](const std::string& name)
|
||||||
|
{
|
||||||
|
params.nameOverride = name;
|
||||||
|
search(params);
|
||||||
|
};
|
||||||
|
|
||||||
|
stop();
|
||||||
|
mWindow->pushGui(new GuiTextEditPopup(mWindow, "SEARCH FOR",
|
||||||
|
// initial value is last search if there was one, otherwise the clean path name
|
||||||
|
params.nameOverride.empty() ? getCleanFileName(params.game->getPath()) : params.nameOverride,
|
||||||
|
searchForFunc, false, "SEARCH"));
|
||||||
|
}
|
||||||
|
|
||||||
std::vector<HelpPrompt> ScraperSearchComponent::getHelpPrompts()
|
std::vector<HelpPrompt> ScraperSearchComponent::getHelpPrompts()
|
||||||
{
|
{
|
||||||
std::vector<HelpPrompt> prompts = mGrid.getHelpPrompts();
|
std::vector<HelpPrompt> prompts = mGrid.getHelpPrompts();
|
||||||
|
|
|
@ -29,6 +29,8 @@ public:
|
||||||
ScraperSearchComponent(Window* window, SearchType searchType = NEVER_AUTO_ACCEPT);
|
ScraperSearchComponent(Window* window, SearchType searchType = NEVER_AUTO_ACCEPT);
|
||||||
|
|
||||||
void search(const ScraperSearchParams& params);
|
void search(const ScraperSearchParams& params);
|
||||||
|
void openInputScreen(ScraperSearchParams& from);
|
||||||
|
void stop();
|
||||||
|
|
||||||
// Metadata assets will be resolved before calling the accept callback (e.g. result.mdl's "image" is automatically downloaded and properly set).
|
// Metadata assets will be resolved before calling the accept callback (e.g. result.mdl's "image" is automatically downloaded and properly set).
|
||||||
inline void setAcceptCallback(const std::function<void(const ScraperSearchResult&)>& acceptCallback) { mAcceptCallback = acceptCallback; }
|
inline void setAcceptCallback(const std::function<void(const ScraperSearchResult&)>& acceptCallback) { mAcceptCallback = acceptCallback; }
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
#include "../components/TextComponent.h"
|
#include "../components/TextComponent.h"
|
||||||
#include "../components/ButtonComponent.h"
|
#include "../components/ButtonComponent.h"
|
||||||
#include "../components/MenuComponent.h"
|
#include "../components/MenuComponent.h"
|
||||||
|
#include "GuiTextEditPopup.h"
|
||||||
|
|
||||||
GuiGameScraper::GuiGameScraper(Window* window, ScraperSearchParams params, std::function<void(const ScraperSearchResult&)> doneFunc) : GuiComponent(window),
|
GuiGameScraper::GuiGameScraper(Window* window, ScraperSearchParams params, std::function<void(const ScraperSearchResult&)> doneFunc) : GuiComponent(window),
|
||||||
mGrid(window, Eigen::Vector2i(1, 3)),
|
mGrid(window, Eigen::Vector2i(1, 3)),
|
||||||
|
@ -27,7 +28,11 @@ GuiGameScraper::GuiGameScraper(Window* window, ScraperSearchParams params, std::
|
||||||
|
|
||||||
// buttons
|
// buttons
|
||||||
std::vector< std::shared_ptr<ButtonComponent> > buttons;
|
std::vector< std::shared_ptr<ButtonComponent> > buttons;
|
||||||
buttons.push_back(std::make_shared<ButtonComponent>(mWindow, "INPUT", "manually search"));
|
|
||||||
|
buttons.push_back(std::make_shared<ButtonComponent>(mWindow, "INPUT", "manually search by name", [&] {
|
||||||
|
mSearch->openInputScreen(mSearchParams);
|
||||||
|
mGrid.resetCursor();
|
||||||
|
}));
|
||||||
buttons.push_back(std::make_shared<ButtonComponent>(mWindow, "CANCEL", "cancel", [&] { delete this; }));
|
buttons.push_back(std::make_shared<ButtonComponent>(mWindow, "CANCEL", "cancel", [&] { delete this; }));
|
||||||
mButtonGrid = makeButtonGrid(mWindow, buttons);
|
mButtonGrid = makeButtonGrid(mWindow, buttons);
|
||||||
|
|
||||||
|
|
|
@ -33,7 +33,10 @@ GuiScraperMulti::GuiScraperMulti(Window* window, const std::queue<ScraperSearchP
|
||||||
mGrid.setEntry(mSearchComp, Vector2i(0, 2), approveResults, true);
|
mGrid.setEntry(mSearchComp, Vector2i(0, 2), approveResults, true);
|
||||||
|
|
||||||
std::vector< std::shared_ptr<ButtonComponent> > buttons;
|
std::vector< std::shared_ptr<ButtonComponent> > buttons;
|
||||||
buttons.push_back(std::make_shared<ButtonComponent>(mWindow, "INPUT", "manually search by name", nullptr));
|
buttons.push_back(std::make_shared<ButtonComponent>(mWindow, "INPUT", "manually search by name", [&] {
|
||||||
|
mSearchComp->openInputScreen(mSearchQueue.front());
|
||||||
|
mGrid.resetCursor();
|
||||||
|
}));
|
||||||
buttons.push_back(std::make_shared<ButtonComponent>(mWindow, "SKIP", "skip this game", std::bind(&GuiScraperMulti::skip, this)));
|
buttons.push_back(std::make_shared<ButtonComponent>(mWindow, "SKIP", "skip this game", std::bind(&GuiScraperMulti::skip, this)));
|
||||||
buttons.push_back(std::make_shared<ButtonComponent>(mWindow, "STOP", "cancel scraping", std::bind(&GuiScraperMulti::finish, this)));
|
buttons.push_back(std::make_shared<ButtonComponent>(mWindow, "STOP", "cancel scraping", std::bind(&GuiScraperMulti::finish, this)));
|
||||||
mButtonGrid = makeButtonGrid(mWindow, buttons);
|
mButtonGrid = makeButtonGrid(mWindow, buttons);
|
||||||
|
|
Loading…
Reference in a new issue