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.Messages;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.ui.RenderedTextBlock;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.ui.Tooltip;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.ui.Window;
|
||||
import com.watabou.gltextures.TextureCache;
|
||||
import com.watabou.glwrap.Blending;
|
||||
|
@ -148,6 +149,8 @@ public class PixelScene extends Scene {
|
|||
}
|
||||
Game.platform.setupFontGenerators(renderedTextPageSize, SPDSettings.systemFont());
|
||||
|
||||
Tooltip.resetLastUsedTime();
|
||||
|
||||
}
|
||||
|
||||
//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 {
|
||||
|
||||
//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 lastUsedTime = -1;
|
||||
|
||||
public static void resetLastUsedTime(){
|
||||
lastUsedTime = -1;
|
||||
tooltipAlpha = -5;
|
||||
}
|
||||
|
||||
private NinePatch bg;
|
||||
private RenderedTextBlock text;
|
||||
|
||||
|
@ -43,13 +48,16 @@ public class Tooltip extends Component {
|
|||
text.text(msg, maxWidth);
|
||||
layout();
|
||||
|
||||
if (lastUsedTime != -1){
|
||||
if (lastUsedTime == -1 || lastUsedTime > Game.timeTotal){
|
||||
tooltipAlpha = -5f;
|
||||
|
||||
} else {
|
||||
float elapsed = Game.timeTotal - lastUsedTime;
|
||||
if (elapsed >= 0.5f || tooltipAlpha < 1f){
|
||||
if (elapsed >= 0.25f || tooltipAlpha < 1f){
|
||||
tooltipAlpha = -5f;
|
||||
}
|
||||
lastUsedTime = Game.timeTotal;
|
||||
}
|
||||
lastUsedTime = Game.timeTotal;
|
||||
bg.alpha(GameMath.gate(0, tooltipAlpha, 1));
|
||||
text.alpha(GameMath.gate(0, tooltipAlpha, 1));
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user