mirror of
https://github.com/GTNewHorizons/Botania.git
synced 2026-11-28 07:55:45 +00:00
Support for images in the lexicon.
This commit is contained in:
1 parent
687b7514fe
commit
ef8e4b951c
10 files changed
+89
-8
No files matched your search
@@ -21,6 +21,11 @@ public class DummyMethodHandler implements IInternalMethodHandler {
|
||||
return dummyPage(key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public LexiconPage imagePage(String key, String resource) {
|
||||
return dummyPage(resource);
|
||||
}
|
||||
|
||||
private LexiconPage dummyPage(String key) {
|
||||
return new PageDummy(key);
|
||||
}
|
||||
|
||||
@@ -24,4 +24,6 @@ public interface IInternalMethodHandler {
|
||||
|
||||
public LexiconPage textPage(String key);
|
||||
|
||||
public LexiconPage imagePage(String key, String resource);
|
||||
|
||||
}
|
||||
@@ -18,6 +18,7 @@ public final class LibResources {
|
||||
public static final String PREFIX_LANG = "/assets/botania/lang/";
|
||||
|
||||
public static final String PREFIX_GUI = PREFIX_MOD + "textures/gui/";
|
||||
public static final String PREFIX_ENTRIES = PREFIX_GUI + "entries/";
|
||||
public static final String PREFIX_MISC = PREFIX_MOD + "textures/misc/";
|
||||
public static final String PREFIX_MODEL = PREFIX_MOD + "textures/model/";
|
||||
|
||||
@@ -25,6 +26,8 @@ public final class LibResources {
|
||||
|
||||
public static final String GUI_LEXICON = PREFIX_GUI + "lexicon.png";
|
||||
|
||||
public static final String ENTRY_FLOWERS = PREFIX_ENTRIES + "flowers.png";
|
||||
|
||||
public static final String[] LANGS = new String[] {
|
||||
"en_US"
|
||||
};
|
||||
|
||||
@@ -13,6 +13,7 @@ package vazkii.botania.common.core.handler;
|
||||
|
||||
import vazkii.botania.api.internal.IInternalMethodHandler;
|
||||
import vazkii.botania.api.page.LexiconPage;
|
||||
import vazkii.botania.common.lexicon.page.PageImage;
|
||||
import vazkii.botania.common.lexicon.page.PageText;
|
||||
|
||||
public class InternalMethodHandler implements IInternalMethodHandler {
|
||||
@@ -21,5 +22,10 @@ public class InternalMethodHandler implements IInternalMethodHandler {
|
||||
public LexiconPage textPage(String key) {
|
||||
return new PageText(key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public LexiconPage imagePage(String key, String resource) {
|
||||
return new PageImage(key, resource);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -14,6 +14,8 @@ package vazkii.botania.common.lexicon;
|
||||
import vazkii.botania.api.BotaniaAPI;
|
||||
import vazkii.botania.api.LexiconCategory;
|
||||
import vazkii.botania.api.LexiconEntry;
|
||||
import vazkii.botania.client.lib.LibResources;
|
||||
import vazkii.botania.common.lexicon.page.PageImage;
|
||||
import vazkii.botania.common.lexicon.page.PageText;
|
||||
import vazkii.botania.common.lib.LibLexicon;
|
||||
|
||||
@@ -38,10 +40,10 @@ public final class LexiconData {
|
||||
|
||||
// BASICS ENTRIES
|
||||
entry = new BLexiconEntry("world", categoryBasics);
|
||||
entry.setLexiconPages(new PageText("0"), new PageText("1"));
|
||||
entry.setLexiconPages(new PageText("0"), new PageText("1"), new PageImage("2", LibResources.ENTRY_FLOWERS));
|
||||
|
||||
entry = new BLexiconEntry("basicConcepts", categoryBasics);
|
||||
entry.setLexiconPages(new PageText("0"), new PageText("1"), new PageText("2"));
|
||||
entry.setLexiconPages(new PageText("0"), new PageText("1"));
|
||||
|
||||
entry = new BLexiconEntry("gettingStarted", categoryBasics);
|
||||
entry.setLexiconPages(new PageText("0"));
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
/**
|
||||
* This class was created by <Vazkii>. It's distributed as
|
||||
* part of the Botania Mod. Get the Source Code in github:
|
||||
* https://github.com/Vazkii/Botania
|
||||
*
|
||||
* Botania is Open Source and distributed under a
|
||||
* Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
|
||||
* (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
|
||||
*
|
||||
* File Created @ [Jan 16, 2014, 6:13:08 PM (GMT)]
|
||||
*/
|
||||
package vazkii.botania.common.lexicon.page;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.client.renderer.texture.TextureManager;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import vazkii.botania.api.internal.IGuiLexiconEntry;
|
||||
import vazkii.botania.api.page.LexiconPage;
|
||||
|
||||
public class PageImage extends LexiconPage {
|
||||
|
||||
ResourceLocation resource;
|
||||
|
||||
public PageImage(String unlocalizedName, String resource) {
|
||||
super(unlocalizedName);
|
||||
this.resource = new ResourceLocation(resource);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderScreen(IGuiLexiconEntry gui, int mx, int my) {
|
||||
TextureManager render = Minecraft.getMinecraft().renderEngine;
|
||||
render.bindTexture(resource);
|
||||
|
||||
GL11.glEnable(GL11.GL_BLEND);
|
||||
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
|
||||
GL11.glColor4f(1F, 1F, 1F, 1F);
|
||||
((GuiScreen) gui).drawTexturedModalRect(gui.getLeft(), gui.getTop(), 0, 0, gui.getWidth(), gui.getHeight());
|
||||
GL11.glDisable(GL11.GL_BLEND);
|
||||
|
||||
int width = gui.getWidth() - 30;
|
||||
int height = gui.getHeight();
|
||||
int x = gui.getLeft() + 16;
|
||||
int y = gui.getTop() + height - 40;
|
||||
PageText.renderText(x, y, width, height, getUnlocalizedName());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -31,16 +31,20 @@ public class PageText extends LexiconPage {
|
||||
|
||||
@Override
|
||||
public void renderScreen(IGuiLexiconEntry gui, int mx, int my) {
|
||||
FontRenderer renderer = Minecraft.getMinecraft().fontRenderer;
|
||||
boolean unicode = renderer.getUnicodeFlag();
|
||||
renderer.setUnicodeFlag(true);
|
||||
String text = StatCollector.translateToLocal(getUnlocalizedName()).replaceAll("&", "\u00a7");
|
||||
String[] textEntries = text.split("<br>");
|
||||
|
||||
int width = gui.getWidth() - 30;
|
||||
int x = gui.getLeft() + 16;
|
||||
int y = gui.getTop();
|
||||
|
||||
renderText(x, y, width, gui.getHeight(), getUnlocalizedName());
|
||||
}
|
||||
|
||||
public static void renderText(int x, int y, int width, int height, String unlocalizedText) {
|
||||
FontRenderer renderer = Minecraft.getMinecraft().fontRenderer;
|
||||
boolean unicode = renderer.getUnicodeFlag();
|
||||
renderer.setUnicodeFlag(true);
|
||||
String text = StatCollector.translateToLocal(unlocalizedText).replaceAll("&", "\u00a7");
|
||||
String[] textEntries = text.split("<br>");
|
||||
|
||||
String lastFormat = "";
|
||||
for(String s : textEntries) {
|
||||
List<String> wrappedLines = new ArrayList();
|
||||
|
||||
@@ -34,7 +34,16 @@ botania.category.tools=Mystical Instruments
|
||||
botania.category.misc=Miscellaneous
|
||||
|
||||
# LEXICON ENTRIES
|
||||
|
||||
# - BASIC
|
||||
# -- THE WORLD
|
||||
botania.entry.world=The World
|
||||
botania.page.world0=The world is fun.<br>This line of text is very long so I can test if line wrap works fine, woo.<br>And this one is kinda long too. &eTesting colors. &cMore colors.
|
||||
botania.page.world1=This is a second page. There will be something here. Eventually.
|
||||
botania.page.world2=Flowers in the wild
|
||||
|
||||
# -- BASIC CONCEPTS
|
||||
botania.entry.basicConcepts=Basic Concepts
|
||||
|
||||
# -- GETTING STARTED
|
||||
botania.entry.gettingStarted=Getting Started
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 3.0 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 25 KiB |
Reference in new issue
Block a user