mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2025-02-16 20:15:38 +00:00
(Android) Added fade-out support to the touch overlay
This commit is contained in:
parent
0c03583f80
commit
c27ee24cc4
|
@ -1171,6 +1171,21 @@ void GuiMenu::openInputDeviceOptions()
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Touch overlay fade-out timer.
|
||||||
|
auto touchOverlayFadeTime = std::make_shared<SliderComponent>(0.0f, 20.0f, 1.0f, "s");
|
||||||
|
touchOverlayFadeTime->setValue(
|
||||||
|
static_cast<float>(Settings::getInstance()->getInt("InputTouchOverlayFadeTime")));
|
||||||
|
s->addWithLabel("TOUCH OVERLAY FADE-OUT TIME", touchOverlayFadeTime);
|
||||||
|
s->addSaveFunc([touchOverlayFadeTime, s] {
|
||||||
|
if (touchOverlayFadeTime->getValue() !=
|
||||||
|
static_cast<float>(Settings::getInstance()->getInt("InputTouchOverlayFadeTime"))) {
|
||||||
|
Settings::getInstance()->setInt("InputTouchOverlayFadeTime",
|
||||||
|
static_cast<int>(touchOverlayFadeTime->getValue()));
|
||||||
|
InputOverlay::getInstance().resetFadeTimer();
|
||||||
|
s->setNeedsSaving();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
// Whether to enable the touch overlay.
|
// Whether to enable the touch overlay.
|
||||||
auto inputTouchOverlay = std::make_shared<SwitchComponent>();
|
auto inputTouchOverlay = std::make_shared<SwitchComponent>();
|
||||||
inputTouchOverlay->setState(Settings::getInstance()->getBool("InputTouchOverlay"));
|
inputTouchOverlay->setState(Settings::getInstance()->getBool("InputTouchOverlay"));
|
||||||
|
@ -1179,12 +1194,10 @@ void GuiMenu::openInputDeviceOptions()
|
||||||
if (Settings::getInstance()->getBool("InputTouchOverlay") !=
|
if (Settings::getInstance()->getBool("InputTouchOverlay") !=
|
||||||
inputTouchOverlay->getState()) {
|
inputTouchOverlay->getState()) {
|
||||||
Settings::getInstance()->setBool("InputTouchOverlay", inputTouchOverlay->getState());
|
Settings::getInstance()->setBool("InputTouchOverlay", inputTouchOverlay->getState());
|
||||||
|
|
||||||
if (Settings::getInstance()->getBool("InputTouchOverlay"))
|
if (Settings::getInstance()->getBool("InputTouchOverlay"))
|
||||||
InputOverlay::getInstance().createButtons();
|
InputOverlay::getInstance().createButtons();
|
||||||
else
|
else
|
||||||
InputOverlay::getInstance().clearButtons();
|
InputOverlay::getInstance().clearButtons();
|
||||||
|
|
||||||
s->setNeedsSaving();
|
s->setNeedsSaving();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -1195,9 +1208,16 @@ void GuiMenu::openInputDeviceOptions()
|
||||||
touchOverlaySize->getParent()
|
touchOverlaySize->getParent()
|
||||||
->getChild(touchOverlaySize->getChildIndex() - 1)
|
->getChild(touchOverlaySize->getChildIndex() - 1)
|
||||||
->setOpacity(DISABLED_OPACITY);
|
->setOpacity(DISABLED_OPACITY);
|
||||||
|
|
||||||
|
touchOverlayFadeTime->setEnabled(false);
|
||||||
|
touchOverlayFadeTime->setOpacity(DISABLED_OPACITY);
|
||||||
|
touchOverlayFadeTime->getParent()
|
||||||
|
->getChild(touchOverlayFadeTime->getChildIndex() - 1)
|
||||||
|
->setOpacity(DISABLED_OPACITY);
|
||||||
}
|
}
|
||||||
|
|
||||||
auto inputTouchOverlayCallback = [this, inputTouchOverlay, touchOverlaySize]() {
|
auto inputTouchOverlayCallback = [this, inputTouchOverlay, touchOverlaySize,
|
||||||
|
touchOverlayFadeTime]() {
|
||||||
if (!inputTouchOverlay->getState()) {
|
if (!inputTouchOverlay->getState()) {
|
||||||
const std::string message {
|
const std::string message {
|
||||||
"DON'T DISABLE THE TOUCH OVERLAY UNLESS YOU ARE USING A CONTROLLER OR YOU WILL "
|
"DON'T DISABLE THE TOUCH OVERLAY UNLESS YOU ARE USING A CONTROLLER OR YOU WILL "
|
||||||
|
@ -1221,6 +1241,12 @@ void GuiMenu::openInputDeviceOptions()
|
||||||
touchOverlaySize->getParent()
|
touchOverlaySize->getParent()
|
||||||
->getChild(touchOverlaySize->getChildIndex() - 1)
|
->getChild(touchOverlaySize->getChildIndex() - 1)
|
||||||
->setOpacity(DISABLED_OPACITY);
|
->setOpacity(DISABLED_OPACITY);
|
||||||
|
|
||||||
|
touchOverlayFadeTime->setEnabled(false);
|
||||||
|
touchOverlayFadeTime->setOpacity(DISABLED_OPACITY);
|
||||||
|
touchOverlayFadeTime->getParent()
|
||||||
|
->getChild(touchOverlayFadeTime->getChildIndex() - 1)
|
||||||
|
->setOpacity(DISABLED_OPACITY);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
touchOverlaySize->setEnabled(true);
|
touchOverlaySize->setEnabled(true);
|
||||||
|
@ -1228,6 +1254,12 @@ void GuiMenu::openInputDeviceOptions()
|
||||||
touchOverlaySize->getParent()
|
touchOverlaySize->getParent()
|
||||||
->getChild(touchOverlaySize->getChildIndex() - 1)
|
->getChild(touchOverlaySize->getChildIndex() - 1)
|
||||||
->setOpacity(1.0f);
|
->setOpacity(1.0f);
|
||||||
|
|
||||||
|
touchOverlayFadeTime->setEnabled(true);
|
||||||
|
touchOverlayFadeTime->setOpacity(1.0f);
|
||||||
|
touchOverlayFadeTime->getParent()
|
||||||
|
->getChild(touchOverlayFadeTime->getChildIndex() - 1)
|
||||||
|
->setOpacity(1.0f);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -896,7 +896,7 @@ int main(int argc, char* argv[])
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(__ANDROID__)
|
#if defined(__ANDROID__)
|
||||||
InputOverlay::getInstance();
|
InputOverlay::getInstance().init();
|
||||||
|
|
||||||
LOG(LogDebug) << "Android API level: " << SDL_GetAndroidSDKVersion();
|
LOG(LogDebug) << "Android API level: " << SDL_GetAndroidSDKVersion();
|
||||||
Utils::Platform::Android::printDeviceInfo();
|
Utils::Platform::Android::printDeviceInfo();
|
||||||
|
|
|
@ -241,6 +241,7 @@ void Settings::setDefaults()
|
||||||
mStringMap["InputControllerType"] = {"xbox", "xbox"};
|
mStringMap["InputControllerType"] = {"xbox", "xbox"};
|
||||||
#if defined(__ANDROID__)
|
#if defined(__ANDROID__)
|
||||||
mStringMap["InputTouchOverlaySize"] = {"medium", "medium"};
|
mStringMap["InputTouchOverlaySize"] = {"medium", "medium"};
|
||||||
|
mIntMap["InputTouchOverlayFadeTime"] = {6, 6};
|
||||||
mBoolMap["InputTouchOverlay"] = {true, true};
|
mBoolMap["InputTouchOverlay"] = {true, true};
|
||||||
#endif
|
#endif
|
||||||
mBoolMap["InputOnlyFirstController"] = {false, false};
|
mBoolMap["InputOnlyFirstController"] = {false, false};
|
||||||
|
|
|
@ -447,6 +447,11 @@ void Window::update(int deltaTime)
|
||||||
|
|
||||||
if (mScreensaver && mRenderScreensaver)
|
if (mScreensaver && mRenderScreensaver)
|
||||||
mScreensaver->update(deltaTime);
|
mScreensaver->update(deltaTime);
|
||||||
|
|
||||||
|
#if defined(__ANDROID__)
|
||||||
|
if (Settings::getInstance()->getBool("InputTouchOverlay"))
|
||||||
|
InputOverlay::getInstance().update(deltaTime);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Window::isBackgroundDimmed()
|
bool Window::isBackgroundDimmed()
|
||||||
|
|
Loading…
Reference in a new issue