2016-06-03 16:56:13 -07:00
|
|
|
package WayofTime.bloodmagic.compat.guideapi.entry;
|
|
|
|
|
|
|
|
import amerifrance.guideapi.api.IPage;
|
|
|
|
import amerifrance.guideapi.api.impl.Book;
|
|
|
|
import amerifrance.guideapi.api.impl.abstraction.CategoryAbstract;
|
|
|
|
import amerifrance.guideapi.api.util.GuiHelper;
|
|
|
|
import amerifrance.guideapi.entry.EntryResourceLocation;
|
|
|
|
import amerifrance.guideapi.gui.GuiBase;
|
|
|
|
import net.minecraft.client.Minecraft;
|
|
|
|
import net.minecraft.client.gui.FontRenderer;
|
|
|
|
import net.minecraft.util.ResourceLocation;
|
|
|
|
import net.minecraftforge.fml.relauncher.Side;
|
|
|
|
import net.minecraftforge.fml.relauncher.SideOnly;
|
|
|
|
|
2016-06-05 17:38:23 -07:00
|
|
|
import java.util.Collections;
|
2016-06-03 16:56:13 -07:00
|
|
|
import java.util.List;
|
|
|
|
|
2017-08-15 21:30:48 -07:00
|
|
|
public class EntryText extends EntryResourceLocation {
|
2016-06-03 16:56:13 -07:00
|
|
|
|
2017-08-15 21:30:48 -07:00
|
|
|
public EntryText(List<IPage> pageList, String unlocEntryName, boolean unicode) {
|
2016-06-03 16:56:13 -07:00
|
|
|
super(pageList, unlocEntryName, new ResourceLocation("bloodmagicguide", "textures/gui/bullet_point.png"), unicode);
|
|
|
|
}
|
|
|
|
|
2017-08-15 21:30:48 -07:00
|
|
|
public EntryText(List<IPage> pageList, String unlocEntryName) {
|
2016-06-03 16:56:13 -07:00
|
|
|
this(pageList, unlocEntryName, false);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@SideOnly(Side.CLIENT)
|
2017-08-15 21:30:48 -07:00
|
|
|
public void drawExtras(Book book, CategoryAbstract category, int entryX, int entryY, int entryWidth, int entryHeight, int mouseX, int mouseY, GuiBase guiBase, FontRenderer fontRendererObj) {
|
2016-06-03 16:56:13 -07:00
|
|
|
Minecraft.getMinecraft().getTextureManager().bindTexture(image);
|
|
|
|
GuiHelper.drawSizedIconWithoutColor(entryX + 4, entryY + 2, 8, 8, 1F);
|
2016-06-05 17:38:23 -07:00
|
|
|
|
|
|
|
boolean startFlag = fontRendererObj.getUnicodeFlag();
|
|
|
|
fontRendererObj.setUnicodeFlag(false);
|
|
|
|
|
|
|
|
// Cutting code ripped from GuiButtonExt#drawButton(...)
|
|
|
|
int strWidth = fontRendererObj.getStringWidth(getLocalizedName());
|
|
|
|
boolean cutString = false;
|
|
|
|
|
|
|
|
if (strWidth > guiBase.xSize - 80 && strWidth > fontRendererObj.getStringWidth("..."))
|
|
|
|
cutString = true;
|
|
|
|
|
2017-08-15 21:30:48 -07:00
|
|
|
if (GuiHelper.isMouseBetween(mouseX, mouseY, entryX, entryY, entryWidth, entryHeight) && cutString) {
|
2016-06-05 17:38:23 -07:00
|
|
|
|
|
|
|
guiBase.drawHoveringText(Collections.singletonList(getLocalizedName()), entryX, entryY + 12);
|
|
|
|
fontRendererObj.setUnicodeFlag(unicode);
|
|
|
|
}
|
|
|
|
|
|
|
|
fontRendererObj.setUnicodeFlag(startFlag);
|
2016-06-03 16:56:13 -07:00
|
|
|
}
|
|
|
|
}
|