mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2024-11-25 23:55:38 +00:00
Redid scraper start menu.
This commit is contained in:
parent
671dbc62c1
commit
b2165dd17b
|
@ -13,6 +13,14 @@ public:
|
|||
|
||||
inline void addRow(const ComponentListRow& row, bool setCursorHere = false) { mList.addRow(row, setCursorHere); }
|
||||
|
||||
inline void addWithLabel(const std::string& label, const std::shared_ptr<GuiComponent>& comp, bool setCursorHere = false)
|
||||
{
|
||||
ComponentListRow row;
|
||||
row.addElement(std::make_shared<TextComponent>(mWindow, label, Font::get(FONT_SIZE_MEDIUM), 0x777777FF), true);
|
||||
row.addElement(comp, false);
|
||||
addRow(row, setCursorHere);
|
||||
}
|
||||
|
||||
private:
|
||||
NinePatchComponent mBackground;
|
||||
TextComponent mTitle;
|
||||
|
|
|
@ -2,58 +2,45 @@
|
|||
#include "GuiScraperLog.h"
|
||||
#include "GuiMsgBoxYesNo.h"
|
||||
|
||||
#include "../components/TextComponent.h"
|
||||
#include "../components/OptionListComponent.h"
|
||||
#include "../components/SwitchComponent.h"
|
||||
|
||||
GuiScraperStart::GuiScraperStart(Window* window) : GuiComponent(window),
|
||||
mBox(window, ":/frame.png"),
|
||||
mList(window, Eigen::Vector2i(2, 4)),
|
||||
mFilterLabel(mWindow),
|
||||
mSystemsLabel(mWindow),
|
||||
mManualLabel(mWindow),
|
||||
mFiltersOpt(mWindow),
|
||||
mSystemsOpt(mWindow, true),
|
||||
mManualSwitch(mWindow),
|
||||
mStartButton(mWindow)
|
||||
mMenu(window, "SCRAPE NOW")
|
||||
{
|
||||
mFilterLabel.setText("Filter: ");
|
||||
mSystemsLabel.setText("Systems: ");
|
||||
mManualLabel.setText("Manual mode: ");
|
||||
addChild(&mMenu);
|
||||
|
||||
addChild(&mBox);
|
||||
addChild(&mList);
|
||||
|
||||
using namespace Eigen;
|
||||
|
||||
//add filters (with first one selected)
|
||||
mFiltersOpt.add("All Games",
|
||||
// add filters (with first one selected)
|
||||
mFilters = std::make_shared< OptionListComponent<GameFilterFunc> >(mWindow, false);
|
||||
mFilters->add("All Games",
|
||||
[](SystemData*, FileData*) -> bool { return true; }, true);
|
||||
mFiltersOpt.add("Missing Image",
|
||||
mFilters->add("Only missing image",
|
||||
[](SystemData*, FileData* g) -> bool { return g->metadata.get("image").empty(); }, false);
|
||||
|
||||
mList.setEntry(Vector2i(0, 0), Vector2i(1, 1), &mFilterLabel, false, ComponentGrid::AlignRight);
|
||||
mList.setEntry(Vector2i(1, 0), Vector2i(1, 1), &mFiltersOpt, true, ComponentGrid::AlignLeft);
|
||||
mMenu.addWithLabel("Filter", mFilters);
|
||||
|
||||
//add systems (all with a platformid specified selected)
|
||||
std::vector<SystemData*> sys = SystemData::sSystemVector;
|
||||
for(auto it = sys.begin(); it != sys.end(); it++)
|
||||
mSystemsOpt.add((*it)->getFullName(), *it, (*it)->getPlatformId() != PlatformIds::PLATFORM_UNKNOWN);
|
||||
mSystems = std::make_shared< OptionListComponent<SystemData*> >(mWindow, true);
|
||||
for(auto it = SystemData::sSystemVector.begin(); it != SystemData::sSystemVector.end(); it++)
|
||||
mSystems->add((*it)->getFullName(), *it, (*it)->getPlatformId() != PlatformIds::PLATFORM_UNKNOWN);
|
||||
mMenu.addWithLabel("Systems", mSystems);
|
||||
|
||||
mList.setEntry(Vector2i(0, 1), Vector2i(1, 1), &mSystemsLabel, false, ComponentGrid::AlignRight);
|
||||
mList.setEntry(Vector2i(1, 1), Vector2i(1, 1), &mSystemsOpt, true, ComponentGrid::AlignLeft);
|
||||
mAutoStyle = std::make_shared< OptionListComponent<int> >(mWindow, false);
|
||||
mAutoStyle->add("Never automatically accept result", 0, true);
|
||||
mAutoStyle->add("Always accept first result", 1, false);
|
||||
mMenu.addWithLabel("Auto style", mAutoStyle);
|
||||
|
||||
mList.setEntry(Vector2i(0, 2), Vector2i(1, 1), &mManualLabel, false, ComponentGrid::AlignRight);
|
||||
mList.setEntry(Vector2i(1, 2), Vector2i(1, 1), &mManualSwitch, true, ComponentGrid::AlignLeft);
|
||||
ComponentListRow row;
|
||||
row.addElement(std::make_shared<TextComponent>(mWindow, "GO GO GO", Font::get(FONT_SIZE_MEDIUM), 0x777777FF), true);
|
||||
row.makeAcceptInputHandler(std::bind(&GuiScraperStart::pressedStart, this));
|
||||
mMenu.addRow(row);
|
||||
|
||||
mStartButton.setText("GO GO GO GO", "begin");
|
||||
mStartButton.setPressedFunc(std::bind(&GuiScraperStart::pressedStart, this));
|
||||
mList.setEntry(Vector2i(0, 3), Vector2i(2, 1), &mStartButton, true, ComponentGrid::AlignCenter);
|
||||
|
||||
mList.setPosition(Renderer::getScreenWidth() / 2 - mList.getSize().x() / 2, Renderer::getScreenHeight() / 2 - mList.getSize().y() / 2);
|
||||
|
||||
mBox.fitTo(mList.getSize(), mList.getPosition(), Eigen::Vector2f(-32, -32));
|
||||
mMenu.setPosition((Renderer::getScreenWidth() - mMenu.getSize().x()) / 2, (Renderer::getScreenHeight() - mMenu.getSize().y()) / 2);
|
||||
}
|
||||
|
||||
void GuiScraperStart::pressedStart()
|
||||
{
|
||||
std::vector<SystemData*> sys = mSystemsOpt.getSelectedObjects();
|
||||
std::vector<SystemData*> sys = mSystems->getSelectedObjects();
|
||||
for(auto it = sys.begin(); it != sys.end(); it++)
|
||||
{
|
||||
if((*it)->getPlatformId() == PlatformIds::PLATFORM_UNKNOWN)
|
||||
|
@ -69,9 +56,9 @@ void GuiScraperStart::pressedStart()
|
|||
|
||||
void GuiScraperStart::start()
|
||||
{
|
||||
std::queue<ScraperSearchParams> searches = getSearches(mSystemsOpt.getSelectedObjects(), mFiltersOpt.getSelectedObjects()[0]);
|
||||
std::queue<ScraperSearchParams> searches = getSearches(mSystems->getSelectedObjects(), mFilters->getSelected());
|
||||
|
||||
GuiScraperLog* gsl = new GuiScraperLog(mWindow, searches, mManualSwitch.getState());
|
||||
GuiScraperLog* gsl = new GuiScraperLog(mWindow, searches, mAutoStyle->getSelected() == 0);
|
||||
mWindow->pushGui(gsl);
|
||||
gsl->start();
|
||||
delete this;
|
||||
|
@ -116,7 +103,7 @@ bool GuiScraperStart::input(InputConfig* config, Input input)
|
|||
|
||||
std::vector<HelpPrompt> GuiScraperStart::getHelpPrompts()
|
||||
{
|
||||
std::vector<HelpPrompt> prompts = mList.getHelpPrompts();
|
||||
std::vector<HelpPrompt> prompts = mMenu.getHelpPrompts();
|
||||
prompts.push_back(HelpPrompt("b", "cancel"));
|
||||
return prompts;
|
||||
}
|
||||
|
|
|
@ -2,16 +2,17 @@
|
|||
|
||||
#include "../GuiComponent.h"
|
||||
#include "../SystemData.h"
|
||||
#include "../components/TextComponent.h"
|
||||
#include "../components/ComponentGrid.h"
|
||||
#include "../components/OptionListComponent.h"
|
||||
#include "../components/SwitchComponent.h"
|
||||
#include "../components/ButtonComponent.h"
|
||||
#include "../scrapers/Scraper.h"
|
||||
#include "../components/MenuComponent.h"
|
||||
#include <queue>
|
||||
|
||||
typedef std::function<bool(SystemData*, FileData*)> GameFilterFunc;
|
||||
|
||||
template<typename T>
|
||||
class OptionListComponent;
|
||||
|
||||
class SwitchComponent;
|
||||
|
||||
//The starting point for a multi-game scrape.
|
||||
//Allows the user to set various parameters (to set filters, to set which systems to scrape, to enable manual mode).
|
||||
//Generates a list of "searches" that will be carried out by GuiScraperLog.
|
||||
|
@ -29,16 +30,9 @@ private:
|
|||
void start();
|
||||
std::queue<ScraperSearchParams> getSearches(std::vector<SystemData*> systems, GameFilterFunc selector);
|
||||
|
||||
NinePatchComponent mBox;
|
||||
ComponentGrid mList;
|
||||
std::shared_ptr< OptionListComponent<GameFilterFunc> > mFilters;
|
||||
std::shared_ptr< OptionListComponent<SystemData*> > mSystems;
|
||||
std::shared_ptr< OptionListComponent<int> > mAutoStyle;
|
||||
|
||||
TextComponent mFilterLabel;
|
||||
TextComponent mSystemsLabel;
|
||||
TextComponent mManualLabel;
|
||||
|
||||
OptionListComponent<GameFilterFunc> mFiltersOpt;
|
||||
OptionListComponent<SystemData*> mSystemsOpt;
|
||||
SwitchComponent mManualSwitch;
|
||||
|
||||
ButtonComponent mStartButton;
|
||||
MenuComponent mMenu;
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue