v1.2.0: fixed cases of tooltips appearing instantly
This commit is contained in:
parent
c32f016dd8
commit
e3a956506c
|
@ -28,6 +28,7 @@ import com.shatteredpixel.shatteredpixeldungeon.effects.BadgeBanner;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.messages.Languages;
|
import com.shatteredpixel.shatteredpixeldungeon.messages.Languages;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
|
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.ui.RenderedTextBlock;
|
import com.shatteredpixel.shatteredpixeldungeon.ui.RenderedTextBlock;
|
||||||
|
import com.shatteredpixel.shatteredpixeldungeon.ui.Tooltip;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.ui.Window;
|
import com.shatteredpixel.shatteredpixeldungeon.ui.Window;
|
||||||
import com.watabou.gltextures.TextureCache;
|
import com.watabou.gltextures.TextureCache;
|
||||||
import com.watabou.glwrap.Blending;
|
import com.watabou.glwrap.Blending;
|
||||||
|
@ -148,6 +149,8 @@ public class PixelScene extends Scene {
|
||||||
}
|
}
|
||||||
Game.platform.setupFontGenerators(renderedTextPageSize, SPDSettings.systemFont());
|
Game.platform.setupFontGenerators(renderedTextPageSize, SPDSettings.systemFont());
|
||||||
|
|
||||||
|
Tooltip.resetLastUsedTime();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//FIXME this system currently only works for a subset of windows
|
//FIXME this system currently only works for a subset of windows
|
||||||
|
|
|
@ -31,10 +31,15 @@ import com.watabou.utils.GameMath;
|
||||||
public class Tooltip extends Component {
|
public class Tooltip extends Component {
|
||||||
|
|
||||||
//tooltips require .5 seconds to appear, fade in over .1 second
|
//tooltips require .5 seconds to appear, fade in over .1 second
|
||||||
//they then persist until none are visible for .5 seconds or more
|
//they then persist until none are visible for .25 seconds or more
|
||||||
private static float tooltipAlpha = -5f;
|
private static float tooltipAlpha = -5f;
|
||||||
private static float lastUsedTime = -1;
|
private static float lastUsedTime = -1;
|
||||||
|
|
||||||
|
public static void resetLastUsedTime(){
|
||||||
|
lastUsedTime = -1;
|
||||||
|
tooltipAlpha = -5;
|
||||||
|
}
|
||||||
|
|
||||||
private NinePatch bg;
|
private NinePatch bg;
|
||||||
private RenderedTextBlock text;
|
private RenderedTextBlock text;
|
||||||
|
|
||||||
|
@ -43,13 +48,16 @@ public class Tooltip extends Component {
|
||||||
text.text(msg, maxWidth);
|
text.text(msg, maxWidth);
|
||||||
layout();
|
layout();
|
||||||
|
|
||||||
if (lastUsedTime != -1){
|
if (lastUsedTime == -1 || lastUsedTime > Game.timeTotal){
|
||||||
|
tooltipAlpha = -5f;
|
||||||
|
|
||||||
|
} else {
|
||||||
float elapsed = Game.timeTotal - lastUsedTime;
|
float elapsed = Game.timeTotal - lastUsedTime;
|
||||||
if (elapsed >= 0.5f || tooltipAlpha < 1f){
|
if (elapsed >= 0.25f || tooltipAlpha < 1f){
|
||||||
tooltipAlpha = -5f;
|
tooltipAlpha = -5f;
|
||||||
}
|
}
|
||||||
lastUsedTime = Game.timeTotal;
|
|
||||||
}
|
}
|
||||||
|
lastUsedTime = Game.timeTotal;
|
||||||
bg.alpha(GameMath.gate(0, tooltipAlpha, 1));
|
bg.alpha(GameMath.gate(0, tooltipAlpha, 1));
|
||||||
text.alpha(GameMath.gate(0, tooltipAlpha, 1));
|
text.alpha(GameMath.gate(0, tooltipAlpha, 1));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user