mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2024-11-25 07:35:38 +00:00
Scraping options not supported by TheGamesDB are now grayed out in the menu.
This required some general logic to be added to disable GUI components, and this functionality could hopefully be useful elsewhere.
This commit is contained in:
parent
2efc5aed93
commit
2c6bc918d6
|
@ -62,8 +62,18 @@ GuiScraperMenu::GuiScraperMenu(Window* window) : GuiComponent(window),
|
|||
}
|
||||
mMenu.addWithLabel("Systems", mSystems);
|
||||
|
||||
addEntry("CONTENT SETTINGS", 0x777777FF, true, [this] { openContentSettings(); });
|
||||
addEntry("OTHER SETTINGS", 0x777777FF, true, [this] { openOtherSettings(); });
|
||||
addEntry("CONTENT SETTINGS", 0x777777FF, true, [this] {
|
||||
// Always save the settings when entering this menu, so the options that are
|
||||
// not supported by TheGamesDB can be disabled.
|
||||
mMenu.save();
|
||||
openContentSettings();
|
||||
});
|
||||
addEntry("OTHER SETTINGS", 0x777777FF, true, [this] {
|
||||
// Always save the settings when entering this menu, so the options that are
|
||||
// not supported by TheGamesDB can be disabled.
|
||||
mMenu.save();
|
||||
openOtherSettings();
|
||||
});
|
||||
|
||||
addChild(&mMenu);
|
||||
|
||||
|
@ -109,6 +119,15 @@ void GuiScraperMenu::openContentSettings()
|
|||
s->addSaveFunc([scrape_ratings] { Settings::getInstance()->setBool("ScrapeRatings",
|
||||
scrape_ratings->getState()); });
|
||||
|
||||
// Ratings are not supported by TheGamesDB, so disable the option if this scraper is selected.
|
||||
if (Settings::getInstance()->getString("Scraper") == "thegamesdb") {
|
||||
scrape_ratings->setDisabled();
|
||||
scrape_ratings->setOpacity(DISABLED_OPACITY);
|
||||
// I'm sure there is a better way to find the text component...
|
||||
scrape_ratings->getParent()->getChild(
|
||||
scrape_ratings->getParent()->getChildCount()-2)->setOpacity(DISABLED_OPACITY);
|
||||
}
|
||||
|
||||
// Scrape other metadata.
|
||||
auto scrape_metadata = std::make_shared<SwitchComponent>(mWindow);
|
||||
scrape_metadata->setState(Settings::getInstance()->getBool("ScrapeMetadata"));
|
||||
|
@ -144,6 +163,16 @@ void GuiScraperMenu::openContentSettings()
|
|||
s->addSaveFunc([scrape_3dboxes] { Settings::getInstance()->setBool("Scrape3DBoxes",
|
||||
scrape_3dboxes->getState()); });
|
||||
|
||||
// 3D box images are not supported by TheGamesDB, so disable the option if this scraper
|
||||
// is selected.
|
||||
if (Settings::getInstance()->getString("Scraper") == "thegamesdb") {
|
||||
scrape_3dboxes->setDisabled();
|
||||
scrape_3dboxes->setOpacity(DISABLED_OPACITY);
|
||||
// I'm sure there is a better way to find the text component...
|
||||
scrape_3dboxes->getParent()->getChild(
|
||||
scrape_3dboxes->getParent()->getChildCount()-2)->setOpacity(DISABLED_OPACITY);
|
||||
}
|
||||
|
||||
mWindow->pushGui(s);
|
||||
}
|
||||
|
||||
|
@ -174,6 +203,15 @@ void GuiScraperMenu::openOtherSettings()
|
|||
Settings::getInstance()->setString("ScraperRegion", scraper_region->getSelected());
|
||||
});
|
||||
|
||||
// Regions are not supported by TheGamesDB, so disable the option if this scraper is selected.
|
||||
if (Settings::getInstance()->getString("Scraper") == "thegamesdb") {
|
||||
scraper_region->setDisabled();
|
||||
scraper_region->setOpacity(DISABLED_OPACITY);
|
||||
// I'm sure there is a better way to find the text component...
|
||||
scraper_region->getParent()->getChild(
|
||||
scraper_region->getParent()->getChildCount()-2)->setOpacity(DISABLED_OPACITY);
|
||||
}
|
||||
|
||||
// Scraper language.
|
||||
auto scraper_language = std::make_shared<OptionListComponent<std::string>>
|
||||
(mWindow, getHelpStyle(), "LANGUAGE", false);
|
||||
|
@ -195,6 +233,15 @@ void GuiScraperMenu::openOtherSettings()
|
|||
Settings::getInstance()->setString("ScraperLanguage", scraper_language->getSelected());
|
||||
});
|
||||
|
||||
// Languages are not supported by TheGamesDB, so disable the option if this scraper is selected.
|
||||
if (Settings::getInstance()->getString("Scraper") == "thegamesdb") {
|
||||
scraper_language->setDisabled();
|
||||
scraper_language->setOpacity(DISABLED_OPACITY);
|
||||
// I'm sure there is a better way to find the text component...
|
||||
scraper_language->getParent()->getChild(
|
||||
scraper_language->getParent()->getChildCount()-2)->setOpacity(DISABLED_OPACITY);
|
||||
}
|
||||
|
||||
// Overwrite files and data.
|
||||
auto scrape_overwrite = std::make_shared<SwitchComponent>(mWindow);
|
||||
scrape_overwrite->setState(Settings::getInstance()->getBool("ScraperOverwriteData"));
|
||||
|
|
|
@ -24,7 +24,8 @@ GuiComponent::GuiComponent(Window* window)
|
|||
mSize(Vector2f::Zero()),
|
||||
mTransform(Transform4x4f::Identity()),
|
||||
mIsProcessing(false),
|
||||
mVisible(true)
|
||||
mVisible(true),
|
||||
mEnabled(true)
|
||||
{
|
||||
for (unsigned char i = 0; i < MAX_ANIMATIONS; i++)
|
||||
mAnimationMap[i] = nullptr;
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
#define ICONCOLOR_USERMARKED 0x5555FFFF
|
||||
#define TEXTCOLOR_SCRAPERMARKED 0x992222FF
|
||||
#define TEXTCOLOR_USERMARKED 0x222299FF
|
||||
#define DISABLED_OPACITY 80
|
||||
|
||||
class Animation;
|
||||
class AnimationController;
|
||||
|
@ -144,6 +145,10 @@ public:
|
|||
virtual void setChangedColor(unsigned int color) { mColorChangedValue = color; };
|
||||
virtual unsigned int getColor() const;
|
||||
|
||||
// These functions are used to enable and disable options in menus, i.e. switches and similar.
|
||||
virtual void setEnabled() { mEnabled = true; };
|
||||
virtual void setDisabled() { mEnabled = false; };
|
||||
|
||||
const Transform4x4f& getTransform();
|
||||
|
||||
virtual std::string getValue() const;
|
||||
|
@ -210,6 +215,7 @@ protected:
|
|||
|
||||
bool mIsProcessing;
|
||||
bool mVisible;
|
||||
bool mEnabled;
|
||||
|
||||
private:
|
||||
// Don't access this directly! Use getTransform()!
|
||||
|
|
|
@ -91,11 +91,17 @@ public:
|
|||
{
|
||||
if (input.value != 0) {
|
||||
if (config->isMappedTo("a", input)) {
|
||||
// Ignore input if the component has been disabled.
|
||||
if (!mEnabled)
|
||||
return true;
|
||||
open();
|
||||
return true;
|
||||
}
|
||||
if (!mMultiSelect) {
|
||||
if (config->isMappedLike("left", input)) {
|
||||
// Ignore input if the component has been disabled.
|
||||
if (!mEnabled)
|
||||
return true;
|
||||
// Move selection to previous.
|
||||
unsigned int i = getSelectedId();
|
||||
int next = (int)i - 1;
|
||||
|
@ -109,6 +115,9 @@ public:
|
|||
|
||||
}
|
||||
else if (config->isMappedLike("right", input)) {
|
||||
// Ignore input if the component has been disabled.
|
||||
if (!mEnabled)
|
||||
return true;
|
||||
// Move selection to next.
|
||||
unsigned int i = getSelectedId();
|
||||
int next = (i + 1) % mEntries.size();
|
||||
|
|
|
@ -30,6 +30,10 @@ void SwitchComponent::onSizeChanged()
|
|||
bool SwitchComponent::input(InputConfig* config, Input input)
|
||||
{
|
||||
if (config->isMappedTo("a", input) && input.value) {
|
||||
// Ignore input if the component has been disabled.
|
||||
if (!mEnabled)
|
||||
return true;
|
||||
|
||||
mState = !mState;
|
||||
onStateChanged();
|
||||
return true;
|
||||
|
@ -72,6 +76,16 @@ void SwitchComponent::setValue(const std::string& statestring)
|
|||
onStateChanged();
|
||||
}
|
||||
|
||||
void SwitchComponent::setOpacity(unsigned char opacity)
|
||||
{
|
||||
mImage.setOpacity(opacity);
|
||||
}
|
||||
|
||||
void SwitchComponent::setColorShift(unsigned int color)
|
||||
{
|
||||
mImage.setColorShift(color);
|
||||
}
|
||||
|
||||
void SwitchComponent::onStateChanged()
|
||||
{
|
||||
mImage.setImage(mState ? ":/graphics/on.svg" : ":/graphics/off.svg");
|
||||
|
|
|
@ -29,6 +29,10 @@ public:
|
|||
void setOriginalColor(unsigned int color) override { mColorOriginalValue = color; };
|
||||
void setChangedColor(unsigned int color) override { mColorChangedValue = color; };
|
||||
|
||||
void setOpacity(unsigned char opacity) override;
|
||||
// Multiply all pixels in the image by this color when rendering.
|
||||
void setColorShift(unsigned int color) override;
|
||||
|
||||
virtual std::vector<HelpPrompt> getHelpPrompts() override;
|
||||
|
||||
private:
|
||||
|
|
Loading…
Reference in a new issue