Apply Review Comments
This commit is contained in:
parent
d6665f1cd5
commit
d2c625e1c9
@ -71,7 +71,7 @@ public interface Helper {
|
|||||||
* @param message The message to display in the popup
|
* @param message The message to display in the popup
|
||||||
*/
|
*/
|
||||||
default void logToast(ITextComponent title, ITextComponent message) {
|
default void logToast(ITextComponent title, ITextComponent message) {
|
||||||
BaritoneToast.addOrUpdate(mc.getToastGui(), title, message, BaritoneAPI.getSettings().toastTimer.value);
|
mc.addScheduledTask(() -> BaritoneToast.addOrUpdate(mc.getToastGui(), title, message, BaritoneAPI.getSettings().toastTimer.value));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -23,25 +23,21 @@ import net.minecraft.client.renderer.GlStateManager;
|
|||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.util.ResourceLocation;
|
||||||
import net.minecraft.util.text.ITextComponent;
|
import net.minecraft.util.text.ITextComponent;
|
||||||
|
|
||||||
public class BaritoneToast implements IToast
|
public class BaritoneToast implements IToast {
|
||||||
{
|
|
||||||
private String title;
|
private String title;
|
||||||
private String subtitle;
|
private String subtitle;
|
||||||
private long firstDrawTime;
|
private long firstDrawTime;
|
||||||
private boolean newDisplay;
|
private boolean newDisplay;
|
||||||
private long totalShowTime;
|
private long totalShowTime;
|
||||||
|
|
||||||
public BaritoneToast(ITextComponent titleComponent, ITextComponent subtitleComponent, long totalShowTime)
|
public BaritoneToast(ITextComponent titleComponent, ITextComponent subtitleComponent, long totalShowTime) {
|
||||||
{
|
|
||||||
this.title = titleComponent.getFormattedText();
|
this.title = titleComponent.getFormattedText();
|
||||||
this.subtitle = subtitleComponent == null ? null : subtitleComponent.getFormattedText();
|
this.subtitle = subtitleComponent == null ? null : subtitleComponent.getFormattedText();
|
||||||
this.totalShowTime = totalShowTime;
|
this.totalShowTime = totalShowTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Visibility draw(GuiToast toastGui, long delta)
|
public Visibility draw(GuiToast toastGui, long delta) {
|
||||||
{
|
if (this.newDisplay) {
|
||||||
if (this.newDisplay)
|
|
||||||
{
|
|
||||||
this.firstDrawTime = delta;
|
this.firstDrawTime = delta;
|
||||||
this.newDisplay = false;
|
this.newDisplay = false;
|
||||||
}
|
}
|
||||||
@ -50,12 +46,9 @@ public class BaritoneToast implements IToast
|
|||||||
GlStateManager.color(1.0F, 1.0F, 1.0F, 255.0f);
|
GlStateManager.color(1.0F, 1.0F, 1.0F, 255.0f);
|
||||||
toastGui.drawTexturedModalRect(0, 0, 0, 32, 160, 32);
|
toastGui.drawTexturedModalRect(0, 0, 0, 32, 160, 32);
|
||||||
|
|
||||||
if (this.subtitle == null)
|
if (this.subtitle == null) {
|
||||||
{
|
|
||||||
toastGui.getMinecraft().fontRenderer.drawString(this.title, 18, 12, -11534256);
|
toastGui.getMinecraft().fontRenderer.drawString(this.title, 18, 12, -11534256);
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
toastGui.getMinecraft().fontRenderer.drawString(this.title, 18, 7, -11534256);
|
toastGui.getMinecraft().fontRenderer.drawString(this.title, 18, 7, -11534256);
|
||||||
toastGui.getMinecraft().fontRenderer.drawString(this.subtitle, 18, 18, -16777216);
|
toastGui.getMinecraft().fontRenderer.drawString(this.subtitle, 18, 18, -16777216);
|
||||||
}
|
}
|
||||||
@ -63,23 +56,18 @@ public class BaritoneToast implements IToast
|
|||||||
return delta - this.firstDrawTime < totalShowTime ? Visibility.SHOW : Visibility.HIDE;
|
return delta - this.firstDrawTime < totalShowTime ? Visibility.SHOW : Visibility.HIDE;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setDisplayedText(ITextComponent titleComponent, ITextComponent subtitleComponent)
|
public void setDisplayedText(ITextComponent titleComponent, ITextComponent subtitleComponent) {
|
||||||
{
|
|
||||||
this.title = titleComponent.getFormattedText();
|
this.title = titleComponent.getFormattedText();
|
||||||
this.subtitle = subtitleComponent == null ? null : subtitleComponent.getFormattedText();
|
this.subtitle = subtitleComponent == null ? null : subtitleComponent.getFormattedText();
|
||||||
this.newDisplay = true;
|
this.newDisplay = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void addOrUpdate(GuiToast toast, ITextComponent title, ITextComponent subtitle, long totalShowTime)
|
public static void addOrUpdate(GuiToast toast, ITextComponent title, ITextComponent subtitle, long totalShowTime) {
|
||||||
{
|
|
||||||
BaritoneToast baritonetoast = toast.getToast(BaritoneToast.class, new Object());
|
BaritoneToast baritonetoast = toast.getToast(BaritoneToast.class, new Object());
|
||||||
|
|
||||||
if (baritonetoast == null)
|
if (baritonetoast == null) {
|
||||||
{
|
|
||||||
toast.add(new BaritoneToast(title, subtitle, totalShowTime));
|
toast.add(new BaritoneToast(title, subtitle, totalShowTime));
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
baritonetoast.setDisplayedText(title, subtitle);
|
baritonetoast.setDisplayedText(title, subtitle);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user