Added persistent message server function

This commit is contained in:
Anuken
2020-02-10 20:22:03 -05:00
parent 3a2fef3bd7
commit 6882a9a355
4 changed files with 60 additions and 8 deletions

View File

@@ -43,6 +43,9 @@ public class HudFragment extends Fragment{
private boolean shown = true;
private float dsize = 47.2f;
private String hudText = "";
private boolean showHudText;
private long lastToast;
public void build(Group parent){
@@ -341,6 +344,19 @@ public class HudFragment extends Fragment{
t.add("$saveload").style(Styles.outlineLabel);
});
parent.fill(p -> {
p.top().table(Styles.black3, t -> t.margin(4).label(() -> hudText)
.style(Styles.outlineLabel)).padTop(10).visible(p.color.a >= 0.001f);
p.update(() -> {
p.color.a = Mathf.lerpDelta(p.color.a, Mathf.num(showHudText), 0.2f);
if(state.is(State.menu)){
p.color.a = 0f;
showHudText = false;
}
});
p.touchable(Touchable.disabled);
});
blockfrag.build(parent);
}
@@ -368,6 +384,15 @@ public class HudFragment extends Fragment{
}
}
public void setHudText(String text){
showHudText = true;
hudText = text;
}
public void toggleHudText(boolean shown){
showHudText = shown;
}
private void scheduleToast(Runnable run){
long duration = (int)(3.5 * 1000);
long since = Time.timeSinceMillis(lastToast);