option menu: partial fix indicator alpha when closing the menu

This commit is contained in:
yugecin 2017-05-28 19:39:09 +02:00
parent 70737e4472
commit 5dc7299ec0

View File

@ -83,6 +83,8 @@ public class OptionsOverlay extends OverlayOpsuState {
/** Selected option indicator hide animation time past. */ /** Selected option indicator hide animation time past. */
private int indicatorHideAnimationTime; private int indicatorHideAnimationTime;
private float showHideProgress;
private Listener listener; private Listener listener;
private Image sliderBallImg; private Image sliderBallImg;
@ -717,15 +719,17 @@ public class OptionsOverlay extends OverlayOpsuState {
if (indicatorHideAnimationTime > INDICATORHIDEANIMATIONTIME) { if (indicatorHideAnimationTime > INDICATORHIDEANIMATIONTIME) {
indicatorHideAnimationTime = INDICATORHIDEANIMATIONTIME; indicatorHideAnimationTime = INDICATORHIDEANIMATIONTIME;
} }
float progress = AnimationEquation.IN_CUBIC.calc((float) indicatorHideAnimationTime / INDICATORHIDEANIMATIONTIME); float progress = AnimationEquation.IN_CUBIC.calc((float) indicatorHideAnimationTime /
COL_INDICATOR.a = (1f - progress) * INDICATOR_ALPHA; INDICATORHIDEANIMATIONTIME);
COL_INDICATOR.a = (1f - progress) * INDICATOR_ALPHA * showHideProgress;
} }
} else if (indicatorHideAnimationTime > 0) { } else if (indicatorHideAnimationTime > 0) {
indicatorHideAnimationTime -= displayContainer.renderDelta * 3; indicatorHideAnimationTime -= displayContainer.renderDelta * 3;
if (indicatorHideAnimationTime < 0) { if (indicatorHideAnimationTime < 0) {
indicatorHideAnimationTime = 0; indicatorHideAnimationTime = 0;
} }
COL_INDICATOR.a = (1f - (float) indicatorHideAnimationTime / INDICATORHIDEANIMATIONTIME) * INDICATOR_ALPHA; COL_INDICATOR.a = (1f - (float) indicatorHideAnimationTime / INDICATORHIDEANIMATIONTIME) *
INDICATOR_ALPHA * showHideProgress;
} }
} }
@ -733,42 +737,41 @@ public class OptionsOverlay extends OverlayOpsuState {
if (acceptInput && animationtime >= SHOWANIMATIONTIME) { if (acceptInput && animationtime >= SHOWANIMATIONTIME) {
// animation already finished // animation already finished
width = targetWidth; width = targetWidth;
showHideProgress = 1f;
return; return;
} }
optionWidth = width - optionStartX - paddingRight; optionWidth = width - optionStartX - paddingRight;
// if acceptInput is false, it means that we're currently hiding ourselves
float progress;
// navigation elemenst fade out with a different animation // navigation elemenst fade out with a different animation
float navProgress; float navProgress;
// if acceptInput is false, it means that we're currently hiding ourselves
if (acceptInput) { if (acceptInput) {
animationtime += delta; animationtime += delta;
if (animationtime >= SHOWANIMATIONTIME) { if (animationtime >= SHOWANIMATIONTIME) {
animationtime = SHOWANIMATIONTIME; animationtime = SHOWANIMATIONTIME;
} }
progress = (float) animationtime / SHOWANIMATIONTIME; showHideProgress = (float) animationtime / SHOWANIMATIONTIME;
navProgress = Utils.clamp(progress * 10f, 0f, 1f); navProgress = Utils.clamp(showHideProgress * 10f, 0f, 1f);
progress = AnimationEquation.OUT_EXPO.calc(progress); showHideProgress = AnimationEquation.OUT_EXPO.calc(showHideProgress);
} else { } else {
animationtime -= delta; animationtime -= delta;
if (animationtime < 0) { if (animationtime < 0) {
animationtime = 0; animationtime = 0;
} }
progress = (float) animationtime / hideAnimationTime; showHideProgress = (float) animationtime / hideAnimationTime;
navProgress = hideAnimationStartProgress * AnimationEquation.IN_CIRC.calc(progress); navProgress = hideAnimationStartProgress * AnimationEquation.IN_CIRC.calc(showHideProgress);
progress = hideAnimationStartProgress * AnimationEquation.IN_EXPO.calc(progress); showHideProgress = hideAnimationStartProgress * AnimationEquation.IN_EXPO.calc(showHideProgress);
} }
width = navButtonSize + (int) (progress * (targetWidth - navButtonSize)); width = navButtonSize + (int) (showHideProgress * (targetWidth - navButtonSize));
COL_NAV_FILTERED.a = COL_NAV_INACTIVE.a = COL_NAV_FILTERED_HOVERED.a = COL_NAV_INDICATOR.a = COL_NAV_FILTERED.a = COL_NAV_INACTIVE.a = COL_NAV_FILTERED_HOVERED.a = COL_NAV_INDICATOR.a =
COL_NAV_WHITE.a = COL_NAV_BG.a = navProgress; COL_NAV_WHITE.a = COL_NAV_BG.a = navProgress;
COL_BG.a = BG_ALPHA * progress; COL_BG.a = BG_ALPHA * showHideProgress;
COL_WHITE.a = progress; COL_WHITE.a = showHideProgress;
COL_PINK.a = progress; COL_PINK.a = showHideProgress;
COL_CYAN.a = progress; COL_CYAN.a = showHideProgress;
COL_GREY.a = progress * LINEALPHA; COL_GREY.a = showHideProgress * LINEALPHA;
COL_BLUE.a = progress; COL_BLUE.a = showHideProgress;
COL_COMBOBOX_HOVER.a = progress; COL_COMBOBOX_HOVER.a = showHideProgress;
COL_INDICATOR.a = progress * (1f - (float) indicatorHideAnimationTime / INDICATORHIDEANIMATIONTIME) * INDICATOR_ALPHA;
} }
@Override @Override