mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2024-11-22 14:15:38 +00:00
More work on multi-game scraping UI.
This commit is contained in:
parent
f3695a7545
commit
ff85f971b2
|
@ -388,7 +388,7 @@ void GuiGameList::updateDetailData()
|
|||
mScreenshot.setPosition(getImagePos() - imgOffset);
|
||||
|
||||
mImageAnimation.fadeIn(35);
|
||||
mImageAnimation.move(imgOffset.x(), imgOffset.y(), 20);
|
||||
mImageAnimation.move((int)imgOffset.x(), (int)imgOffset.y(), 20);
|
||||
|
||||
mDescContainer.setPosition(Eigen::Vector3f(Renderer::getScreenWidth() * 0.03f, getImagePos().y() + mScreenshot.getSize().y() + 12, 0));
|
||||
mDescContainer.setSize(Eigen::Vector2f(Renderer::getScreenWidth() * (mTheme->getFloat("listOffsetX") - 0.03f), Renderer::getScreenHeight() - mDescContainer.getPosition().y()));
|
||||
|
|
|
@ -7,8 +7,9 @@ GuiScraperStart::GuiScraperStart(Window* window) : GuiComponent(window),
|
|||
mSystemsLabel(mWindow),
|
||||
mManualLabel(mWindow),
|
||||
mFiltersOpt(mWindow),
|
||||
mSystemsOpt(mWindow),
|
||||
mManualSwitch(mWindow)
|
||||
mSystemsOpt(mWindow, true),
|
||||
mManualSwitch(mWindow),
|
||||
mStartButton(mWindow)
|
||||
{
|
||||
mFilterLabel.setText("Filter: ");
|
||||
mSystemsLabel.setText("Systems: ");
|
||||
|
@ -18,15 +19,77 @@ GuiScraperStart::GuiScraperStart(Window* window) : GuiComponent(window),
|
|||
addChild(&mList);
|
||||
|
||||
using namespace Eigen;
|
||||
|
||||
//add filters (with first one selected)
|
||||
mFiltersOpt.addEntry(mFiltersOpt.makeEntry("All Games",
|
||||
[](SystemData*, GameData*) -> bool { return true; }, true));
|
||||
mFiltersOpt.addEntry(mFiltersOpt.makeEntry("Missing Image",
|
||||
[](SystemData*, GameData* g) -> bool { return g->metadata()->get("image").empty(); }));
|
||||
|
||||
mList.setEntry(Vector2i(0, 0), Vector2i(1, 1), &mFilterLabel, false, ComponentListComponent::AlignRight);
|
||||
mList.setEntry(Vector2i(1, 0), Vector2i(1, 1), &mFiltersOpt, true, ComponentListComponent::AlignCenter);
|
||||
mList.setEntry(Vector2i(1, 0), Vector2i(1, 1), &mFiltersOpt, true, ComponentListComponent::AlignLeft);
|
||||
|
||||
//add systems (with all selected)
|
||||
std::vector<SystemData*> sys = SystemData::sSystemVector;
|
||||
mSystemsOpt.populate(sys,
|
||||
[&](SystemData* s) {
|
||||
return mSystemsOpt.makeEntry(s->getName(), s, true);
|
||||
});
|
||||
|
||||
mList.setEntry(Vector2i(0, 1), Vector2i(1, 1), &mSystemsLabel, false, ComponentListComponent::AlignRight);
|
||||
mList.setEntry(Vector2i(1, 1), Vector2i(1, 1), &mSystemsOpt, true, ComponentListComponent::AlignCenter);
|
||||
mList.setEntry(Vector2i(1, 1), Vector2i(1, 1), &mSystemsOpt, true, ComponentListComponent::AlignLeft);
|
||||
|
||||
mList.setEntry(Vector2i(0, 2), Vector2i(1, 1), &mManualLabel, false, ComponentListComponent::AlignRight);
|
||||
mList.setEntry(Vector2i(1, 2), Vector2i(1, 1), &mManualSwitch, true, ComponentListComponent::AlignCenter);
|
||||
mList.setEntry(Vector2i(1, 2), Vector2i(1, 1), &mManualSwitch, true, ComponentListComponent::AlignLeft);
|
||||
|
||||
mBox.fitTo(mList.getSize());
|
||||
mStartButton.setText("GO GO GO GO", 0x00FF00FF);
|
||||
mStartButton.setPressedFunc(std::bind(&GuiScraperStart::start, this));
|
||||
mList.setEntry(Vector2i(0, 3), Vector2i(2, 1), &mStartButton, true, ComponentListComponent::AlignCenter);
|
||||
|
||||
mList.setPosition(Renderer::getScreenWidth() / 2 - mList.getSize().x() / 2, Renderer::getScreenHeight() / 2 - mList.getSize().y() / 2);
|
||||
|
||||
mBox.setEdgeColor(0x333333FF);
|
||||
mBox.fitTo(mList.getSize(), mList.getPosition(), Eigen::Vector2f(8, 8));
|
||||
}
|
||||
|
||||
void GuiScraperStart::start()
|
||||
{
|
||||
std::queue<ScraperSearchParams> searches = getSearches(mSystemsOpt.getSelectedObjects(), mFiltersOpt.getSelectedObjects()[0]);
|
||||
}
|
||||
|
||||
std::queue<ScraperSearchParams> GuiScraperStart::getSearches(std::vector<SystemData*> systems, GameFilterFunc selector)
|
||||
{
|
||||
std::queue<ScraperSearchParams> queue;
|
||||
for(auto sys = systems.begin(); sys != systems.end(); sys++)
|
||||
{
|
||||
std::vector<FileData*> games = (*sys)->getRootFolder()->getFilesRecursive(true);
|
||||
for(auto game = games.begin(); game != games.end(); game++)
|
||||
{
|
||||
if(selector((*sys), (GameData*)(*game)))
|
||||
{
|
||||
ScraperSearchParams search;
|
||||
search.game = (GameData*)(*game);
|
||||
search.system = *sys;
|
||||
|
||||
queue.push(search);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return queue;
|
||||
}
|
||||
|
||||
bool GuiScraperStart::input(InputConfig* config, Input input)
|
||||
{
|
||||
bool consumed = GuiComponent::input(config, input);
|
||||
if(consumed)
|
||||
return true;
|
||||
|
||||
if(input.value != 0 && config->isMappedTo("b", input))
|
||||
{
|
||||
delete this;
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -6,13 +6,23 @@
|
|||
#include "ComponentListComponent.h"
|
||||
#include "OptionListComponent.h"
|
||||
#include "SwitchComponent.h"
|
||||
#include "ButtonComponent.h"
|
||||
#include "../scrapers/Scraper.h"
|
||||
#include <queue>
|
||||
|
||||
typedef std::function<bool(SystemData*, GameData*)> GameFilterFunc;
|
||||
|
||||
class GuiScraperStart : public GuiComponent
|
||||
{
|
||||
public:
|
||||
GuiScraperStart(Window* window);
|
||||
|
||||
bool input(InputConfig* config, Input input) override;
|
||||
|
||||
private:
|
||||
void start();
|
||||
std::queue<ScraperSearchParams> getSearches(std::vector<SystemData*> systems, GameFilterFunc selector);
|
||||
|
||||
NinePatchComponent mBox;
|
||||
ComponentListComponent mList;
|
||||
|
||||
|
@ -20,9 +30,11 @@ private:
|
|||
TextComponent mSystemsLabel;
|
||||
TextComponent mManualLabel;
|
||||
|
||||
OptionListComponent<unsigned int> mFiltersOpt;
|
||||
OptionListComponent<GameFilterFunc> mFiltersOpt;
|
||||
OptionListComponent<SystemData*> mSystemsOpt;
|
||||
SwitchComponent mManualSwitch;
|
||||
|
||||
ButtonComponent mStartButton;
|
||||
};
|
||||
|
||||
/*
|
||||
|
|
|
@ -65,7 +65,7 @@ GuiSettingsMenu::GuiSettingsMenu(Window* window) : GuiComponent(window),
|
|||
scrapers.push_back(std::shared_ptr<Scraper>(new GamesDBScraper()));
|
||||
scrapers.push_back(std::shared_ptr<Scraper>(new TheArchiveScraper()));
|
||||
mScraperOptList.populate(scrapers, [&] (const std::shared_ptr<Scraper>& s) {
|
||||
return mScraperOptList.makeEntry(s->getName(), 0x00FF00FF, s, s->getName() == Settings::getInstance()->getScraper()->getName());
|
||||
return mScraperOptList.makeEntry(s->getName(), s, s->getName() == Settings::getInstance()->getScraper()->getName());
|
||||
} );
|
||||
|
||||
mList.setEntry(Vector2i(1, 3), Vector2i(1, 1), &mScraperOptList, true, ComponentListComponent::AlignCenter);
|
||||
|
|
|
@ -17,12 +17,12 @@ public:
|
|||
OptionListComponent(Window* window, bool multiSelect = false) : GuiComponent(window),
|
||||
mCursor(0), mScrollOffset(0), mMultiSelect(multiSelect), mEditing(false), mBox(window, ":/textbox.png")
|
||||
{
|
||||
setSize(getFont()->sizeText("Not set"));
|
||||
}
|
||||
|
||||
struct ListEntry
|
||||
{
|
||||
std::string text;
|
||||
unsigned int color;
|
||||
bool selected;
|
||||
T object;
|
||||
};
|
||||
|
@ -149,9 +149,12 @@ public:
|
|||
renderChildren(parentTrans * getTransform());
|
||||
}
|
||||
|
||||
ListEntry makeEntry(const std::string& name, unsigned int color, T obj, bool selected = false) const
|
||||
ListEntry makeEntry(const std::string& name, T obj, bool selected = false) const
|
||||
{
|
||||
ListEntry e = {name, color, selected, obj};
|
||||
ListEntry e;
|
||||
e.text = name;
|
||||
e.object = obj;
|
||||
e.selected = selected;
|
||||
return e;
|
||||
}
|
||||
|
||||
|
@ -184,6 +187,19 @@ public:
|
|||
|
||||
return ret;
|
||||
}
|
||||
|
||||
std::vector<T> getSelectedObjects()
|
||||
{
|
||||
std::vector<T> ret;
|
||||
for(auto it = mEntries.begin(); it != mEntries.end(); it++)
|
||||
{
|
||||
if((*it).selected)
|
||||
ret.push_back(it->object);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
private:
|
||||
void select(unsigned int i)
|
||||
{
|
||||
|
@ -205,6 +221,7 @@ private:
|
|||
|
||||
void open()
|
||||
{
|
||||
mCursor = 0;
|
||||
mEditing = true;
|
||||
}
|
||||
|
||||
|
@ -222,7 +239,7 @@ private:
|
|||
newSize[1] = (float)font->getHeight();
|
||||
for(unsigned int i = 0; i < mEntries.size(); i++)
|
||||
{
|
||||
cache = font->buildTextCache(mEntries.at(i).text, 0, 0, mEntries.at(i).color);
|
||||
cache = font->buildTextCache(mEntries.at(i).text, 0, 0, 0x000000FF);
|
||||
mTextCaches.push_back(cache);
|
||||
|
||||
if(cache->metrics.size.x() > newSize.x())
|
||||
|
|
Loading…
Reference in a new issue