mirror of
https://github.com/GTNewHorizons/Botania.git
synced 2026-11-18 11:19:19 +00:00
Lexica botania redesign. Part 1.
This commit is contained in:
1 parent
8bc9f81860
commit
d824024fea
18 files changed
+111
-28
No files matched your search
@@ -42,6 +42,7 @@ public final class ShaderHelper {
|
||||
public static int terraPlateRune = 0;
|
||||
public static int filmGrain = 0;
|
||||
public static int gold = 0;
|
||||
public static int categoryButton = 0;
|
||||
|
||||
public static void initShaders() {
|
||||
if(!useShaders())
|
||||
@@ -56,6 +57,7 @@ public final class ShaderHelper {
|
||||
terraPlateRune = createProgram(null, LibResources.SHADER_TERRA_PLATE_RUNE_FRAG);
|
||||
filmGrain = createProgram(null, LibResources.SHADER_FILM_GRAIN_FRAG);
|
||||
gold = createProgram(null, LibResources.SHADER_GOLD_FRAG);
|
||||
categoryButton = createProgram(null, LibResources.SHADER_CATEGORY_BUTTON_FRAG);
|
||||
}
|
||||
|
||||
public static void useShader(int shader, ShaderCallback callback) {
|
||||
|
||||
@@ -100,6 +100,7 @@ public class GuiLexicon extends GuiScreen {
|
||||
public static boolean notesEnabled;
|
||||
static int notesMoveTime;
|
||||
public String note = "";
|
||||
public String categoryHighlight = "";
|
||||
|
||||
List<LexiconCategory> allCategories;
|
||||
|
||||
@@ -151,29 +152,31 @@ public class GuiLexicon extends GuiScreen {
|
||||
for(int i = 0; i < categories + 1; i++) {
|
||||
LexiconCategory category = null;
|
||||
category = i >= categories ? null : allCategories.get(i);
|
||||
int x = i % 4;
|
||||
int y = i / 4;
|
||||
int perline = 5;
|
||||
int x = i % perline;
|
||||
int y = i / perline;
|
||||
|
||||
int size = 27;
|
||||
GuiButtonCategory button = new GuiButtonCategory(i, left + 18 + x * size, top + 37 + y * size, this, category);
|
||||
int size = 22;
|
||||
GuiButtonCategory button = new GuiButtonCategory(i, left + 18 + x * size, top + 50 + y * size, this, category);
|
||||
buttonList.add(button);
|
||||
}
|
||||
}
|
||||
populateBookmarks();
|
||||
if(isMainPage()) {
|
||||
buttonList.add(new GuiButtonOptions(-1, left - 6, top + 13));
|
||||
buttonList.add(new GuiButtonAchievement(-2, left - 6, top + 26));
|
||||
buttonList.add(new GuiButtonChallenges(-3, left - 6, top + 40));
|
||||
buttonList.add(new GuiButtonOptions(-1, left - 6, top + guiHeight - 54));
|
||||
buttonList.add(new GuiButtonAchievement(-2, left - 6, top + guiHeight - 40));
|
||||
buttonList.add(new GuiButtonChallenges(-3, left - 6, top + guiHeight - 25));
|
||||
|
||||
GuiButtonUpdateWarning button = new GuiButtonUpdateWarning(-4, left - 6, top + 60);
|
||||
GuiButtonUpdateWarning button = new GuiButtonUpdateWarning(-4, left - 6, top + guiHeight - 70);
|
||||
buttonList.add(button);
|
||||
|
||||
if(PersistentVariableHelper.lastBotaniaVersion.equals(LibMisc.VERSION)) {
|
||||
button.enabled = false;
|
||||
button.visible = false;
|
||||
}
|
||||
|
||||
if(Calendar.getInstance().get(Calendar.MONTH) == Calendar.NOVEMBER && Calendar.getInstance().get(Calendar.DATE) == 22)
|
||||
buttonList.add(new GuiButtonDoot(-99, left + 110, top + 12));
|
||||
buttonList.add(new GuiButtonDoot(-99, left + 100, top + 12));
|
||||
}
|
||||
|
||||
buttonList.add(new GuiButtonNotes(this, NOTES_BUTTON_ID, left - 4, top - 4));
|
||||
@@ -314,15 +317,23 @@ public class GuiLexicon extends GuiScreen {
|
||||
|
||||
void drawHeader() {
|
||||
GL11.glPushMatrix();
|
||||
float s = 1.5F;
|
||||
GL11.glScalef(s, s, s);
|
||||
GL11.glColor4f(1F, 1F, 1F, 1F);
|
||||
Minecraft.getMinecraft().renderEngine.bindTexture(texture);
|
||||
drawTexturedModalRect(left - 8, top + 9, 0, 224, 140, 31);
|
||||
|
||||
int color = 0xffd200;
|
||||
boolean unicode = fontRendererObj.getUnicodeFlag();
|
||||
fontRendererObj.drawString(title, left + 18, top + 13, color);
|
||||
fontRendererObj.setUnicodeFlag(true);
|
||||
fontRendererObj.drawString(title, (int) ((left + 18) / s), (int) ((top + 10) / s), 0);
|
||||
GL11.glScalef(1F / s, 1F / s, 1F / s);
|
||||
fontRendererObj.drawString(String.format(StatCollector.translateToLocal("botaniamisc.edition"), ItemLexicon.getEdition()), left + 24, top + 23, 0);
|
||||
fontRendererObj.drawString(String.format(StatCollector.translateToLocal("botaniamisc.edition"), ItemLexicon.getEdition()), left + 24, top + 22, color);
|
||||
|
||||
String s = EnumChatFormatting.BOLD + categoryHighlight;
|
||||
fontRendererObj.drawString(s, left + guiWidth / 2 - fontRendererObj.getStringWidth(s) / 2, top + 36, 0);
|
||||
|
||||
fontRendererObj.setUnicodeFlag(unicode);
|
||||
GL11.glPopMatrix();
|
||||
|
||||
categoryHighlight = "";
|
||||
}
|
||||
|
||||
boolean isMainPage() {
|
||||
|
||||
@@ -13,26 +13,68 @@ package vazkii.botania.client.gui.lexicon.button;
|
||||
import java.util.Arrays;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.entity.RenderItem;
|
||||
import net.minecraft.client.renderer.texture.ITextureObject;
|
||||
import net.minecraft.client.renderer.texture.TextureManager;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.StatCollector;
|
||||
import net.minecraftforge.client.MinecraftForgeClient;
|
||||
|
||||
import org.lwjgl.opengl.ARBMultitexture;
|
||||
import org.lwjgl.opengl.ARBShaderObjects;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import org.lwjgl.opengl.GL13;
|
||||
import org.lwjgl.opengl.GL20;
|
||||
|
||||
import com.sun.prism.ps.Shader;
|
||||
|
||||
import vazkii.botania.api.internal.ShaderCallback;
|
||||
import vazkii.botania.api.lexicon.LexiconCategory;
|
||||
import vazkii.botania.client.core.handler.ClientTickHandler;
|
||||
import vazkii.botania.client.core.helper.RenderHelper;
|
||||
import vazkii.botania.client.core.helper.ShaderHelper;
|
||||
import vazkii.botania.client.gui.lexicon.GuiLexicon;
|
||||
import vazkii.botania.client.lib.LibResources;
|
||||
|
||||
public class GuiButtonCategory extends GuiButtonLexicon {
|
||||
|
||||
private static final ResourceLocation fallbackResource = new ResourceLocation(LibResources.CATEGORY_INDEX);
|
||||
private static final ResourceLocation stencilResource = new ResourceLocation(LibResources.GUI_STENCIL);
|
||||
|
||||
private ShaderCallback shaderCallback = new ShaderCallback() {
|
||||
|
||||
@Override
|
||||
public void call(int shader) {
|
||||
TextureManager r = Minecraft.getMinecraft().renderEngine;
|
||||
int heightMatchUniform = ARBShaderObjects.glGetUniformLocationARB(shader, "heightMatch");
|
||||
int imageUniform = ARBShaderObjects.glGetUniformLocationARB(shader, "image");
|
||||
int maskUniform = ARBShaderObjects.glGetUniformLocationARB(shader, "mask");
|
||||
|
||||
float heightMatch = ticksHovered / time;
|
||||
GL13.glActiveTexture(ARBMultitexture.GL_TEXTURE0_ARB);
|
||||
GL11.glBindTexture(GL11.GL_TEXTURE_2D, r.getTexture(resource).getGlTextureId());
|
||||
ARBShaderObjects.glUniform1iARB(imageUniform, 0);
|
||||
|
||||
GL13.glActiveTexture(ARBMultitexture.GL_TEXTURE15_ARB);
|
||||
GL11.glEnable(GL11.GL_TEXTURE_2D);
|
||||
GL11.glBindTexture(GL11.GL_TEXTURE_2D, r.getTexture(stencilResource).getGlTextureId());
|
||||
ARBShaderObjects.glUniform1iARB(maskUniform, 15);
|
||||
|
||||
ARBShaderObjects.glUniform1fARB(heightMatchUniform, heightMatch);
|
||||
GL13.glActiveTexture(ARBMultitexture.GL_TEXTURE0_ARB);
|
||||
}
|
||||
};
|
||||
static boolean boundStencil = false;
|
||||
|
||||
GuiLexicon gui;
|
||||
LexiconCategory category;
|
||||
ResourceLocation resource = null;
|
||||
float ticksHovered = 0F;
|
||||
float time = 5F;
|
||||
int activeTex = 0;
|
||||
|
||||
public GuiButtonCategory(int id, int x, int y, GuiLexicon gui, LexiconCategory category) {
|
||||
super(id, x, y, 24, 24, "");
|
||||
super(id, x, y, 16, 16, "");
|
||||
this.gui = gui;
|
||||
this.category = category;
|
||||
}
|
||||
@@ -40,33 +82,41 @@ public class GuiButtonCategory extends GuiButtonLexicon {
|
||||
@Override
|
||||
public void drawButton(Minecraft mc, int mx, int my) {
|
||||
boolean inside = mx >= xPosition && my >= yPosition && mx < xPosition + width && my < yPosition + height;
|
||||
float time = 5F;
|
||||
if(inside)
|
||||
ticksHovered = Math.min(time, ticksHovered + gui.timeDelta);
|
||||
else ticksHovered = Math.max(0F, ticksHovered - gui.timeDelta);
|
||||
|
||||
ResourceLocation resource;
|
||||
if(category == null)
|
||||
resource = fallbackResource;
|
||||
else resource = category.getIcon();
|
||||
if(resource == null)
|
||||
resource = fallbackResource;
|
||||
if(resource == null) {
|
||||
if(category == null)
|
||||
resource = fallbackResource;
|
||||
else resource = category.getIcon();
|
||||
if(resource == null)
|
||||
resource = fallbackResource;
|
||||
}
|
||||
|
||||
mc.renderEngine.bindTexture(resource);
|
||||
float s = 1F / 48F;
|
||||
float defAlpha = 0.3F;
|
||||
float s = 1F / 32F;
|
||||
float defAlpha = 0F;
|
||||
float alpha = ticksHovered / time * (1F - defAlpha) + defAlpha;
|
||||
|
||||
GL11.glPushMatrix();
|
||||
GL11.glColor4f(1F, 1F, 1F, alpha);
|
||||
GL11.glEnable(GL11.GL_BLEND);
|
||||
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
|
||||
GL11.glScalef(0.5F, 0.5F, 0.5F);
|
||||
RenderHelper.drawTexturedModalRect(xPosition * 2, yPosition * 2, zLevel * 2, 0, 0, 48, 48, s, s);
|
||||
GL11.glColor4f(1F, 1F, 1F, 1F);
|
||||
|
||||
if(!boundStencil) { // Allow for the texture manager to take care of the ResourceLocation before we use it directly with gl
|
||||
mc.renderEngine.bindTexture(stencilResource);
|
||||
boundStencil = true;
|
||||
}
|
||||
mc.renderEngine.bindTexture(resource);
|
||||
|
||||
ShaderHelper.useShader(ShaderHelper.categoryButton, shaderCallback);
|
||||
RenderHelper.drawTexturedModalRect(xPosition * 2, yPosition * 2, zLevel * 2, 0, 0, 32, 32, s, s);
|
||||
ShaderHelper.releaseShader();
|
||||
GL11.glPopMatrix();
|
||||
|
||||
if(inside)
|
||||
RenderHelper.renderTooltipGreen(mx, my, Arrays.asList(StatCollector.translateToLocal(getTooltipText())));
|
||||
gui.categoryHighlight = StatCollector.translateToLocal(getTooltipText());
|
||||
}
|
||||
|
||||
String getTooltipText() {
|
||||
|
||||
@@ -45,6 +45,7 @@ public final class LibResources {
|
||||
public static final String GUI_NEI_BREWERY = PREFIX_GUI + "neiBrewery.png";
|
||||
public static final String GUI_FLOWER_BAG = PREFIX_GUI + "flowerBag.png";
|
||||
public static final String GUI_HUD_ICONS = PREFIX_GUI + "hudIcons.png";
|
||||
public static final String GUI_STENCIL = PREFIX_GUI + "stencil.png";
|
||||
|
||||
public static final String ENTRY_FLOWERS = PREFIX_ENTRIES + "flowers.png";
|
||||
public static final String ENTRY_APOTHECARY = PREFIX_ENTRIES + "apothecary.png";
|
||||
@@ -140,5 +141,6 @@ public final class LibResources {
|
||||
public static final String SHADER_TERRA_PLATE_RUNE_FRAG = PREFIX_SHADER + "terra_plate_rune.frag";
|
||||
public static final String SHADER_FILM_GRAIN_FRAG = PREFIX_SHADER + "film_grain.frag";
|
||||
public static final String SHADER_GOLD_FRAG = PREFIX_SHADER + "gold.frag";
|
||||
public static final String SHADER_CATEGORY_BUTTON_FRAG = PREFIX_SHADER + "category_button.frag";
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user