mirror of
https://github.com/HbmMods/Hbm-s-Nuclear-Tech-GIT.git
synced 2026-01-25 10:32:49 +00:00
changes to the gui; save-dependent info and i18n
This commit is contained in:
parent
a0332d4241
commit
3526af3bdb
@ -30,7 +30,12 @@ public class GUIBookLore extends GuiScreen {
|
||||
|
||||
private World world; //Used for save-dependent information, like the MKU recipe
|
||||
private BookLoreType type;
|
||||
private GUIAppearance setup;
|
||||
|
||||
public int itemTexture;
|
||||
|
||||
protected GUIPage mainPage;
|
||||
protected GUIPage auxPage;
|
||||
protected GUIPageButton button;
|
||||
|
||||
int page = 0;
|
||||
int maxPage;
|
||||
@ -39,18 +44,22 @@ public class GUIBookLore extends GuiScreen {
|
||||
|
||||
world = player.worldObj;
|
||||
type = BookLoreType.getTypeFromStack(player.getHeldItem());
|
||||
setup = type.appearance;
|
||||
GUIAppearance setup = type.appearance;
|
||||
|
||||
if(setup.mainPage.isTwoPages && type.pages <= 1) {
|
||||
xSize = setup.auxPage.sizeX;
|
||||
ySize = setup.auxPage.sizeY;
|
||||
mainPage = setup.mainPage;
|
||||
auxPage = setup.auxPage;
|
||||
button = setup.button;
|
||||
itemTexture = setup.itemTexture;
|
||||
|
||||
if(type.pages <= 1) {
|
||||
xSize = auxPage.sizeX;
|
||||
ySize = auxPage.sizeY;
|
||||
} else {
|
||||
xSize = setup.mainPage.sizeX;
|
||||
ySize = setup.mainPage.sizeY;
|
||||
xSize = mainPage.sizeX;
|
||||
ySize = mainPage.sizeY;
|
||||
}
|
||||
|
||||
maxPage = setup.mainPage.isTwoPages ? (int)Math.ceil(type.pages / 2D) - 1 : type.pages - 1;
|
||||
System.out.print((int)Math.ceil(type.pages / 2D) - 1);
|
||||
maxPage = mainPage.isTwoPages ? (int)Math.ceil(type.pages / 2D) - 1 : type.pages - 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -73,40 +82,44 @@ public class GUIBookLore extends GuiScreen {
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
|
||||
if(page == maxPage && (page + 1) * 2 > type.pages) { //odd numbered pages
|
||||
Minecraft.getMinecraft().getTextureManager().bindTexture(setup.auxPage.texture);
|
||||
func_146110_a(guiLeft, guiTop, setup.auxPage.u, setup.auxPage.v, setup.auxPage.sizeX, setup.auxPage.sizeY, 512, 512);
|
||||
Minecraft.getMinecraft().getTextureManager().bindTexture(auxPage.texture);
|
||||
func_146110_a(guiLeft, guiTop, auxPage.u, auxPage.v, auxPage.sizeX, auxPage.sizeY, 512, 512);
|
||||
} else {
|
||||
Minecraft.getMinecraft().getTextureManager().bindTexture(setup.mainPage.texture);
|
||||
func_146110_a(guiLeft, guiTop, setup.mainPage.u, setup.mainPage.v, setup.mainPage.sizeX, setup.mainPage.sizeY, 512, 512);
|
||||
Minecraft.getMinecraft().getTextureManager().bindTexture(mainPage.texture);
|
||||
func_146110_a(guiLeft, guiTop, mainPage.u, mainPage.v, mainPage.sizeX, mainPage.sizeY, 512, 512);
|
||||
}
|
||||
|
||||
int width = page == maxPage && (page + 1) * 2 > type.pages ? setup.auxPage.sizeX : setup.mainPage.sizeX;
|
||||
int width = page == maxPage && (page + 1) * 2 > type.pages ? auxPage.sizeX : mainPage.sizeX;
|
||||
|
||||
if(page > 0)
|
||||
setup.button.renderButton(this, width, guiLeft, guiTop, false, i, j);
|
||||
button.renderButton(this, width, guiLeft, guiTop, false, i, j);
|
||||
|
||||
if(page < maxPage)
|
||||
setup.button.renderButton(this, width, guiLeft, guiTop, true, i, j);
|
||||
button.renderButton(this, width, guiLeft, guiTop, true, i, j);
|
||||
}
|
||||
|
||||
protected void drawGuiContainerForegroundLayer(int x, int y) {
|
||||
String key = "book_lore." + type.keyI18n + ".page.";
|
||||
|
||||
if(setup.mainPage.isTwoPages) {
|
||||
int defacto = this.page * 2 + 1;
|
||||
if(mainPage.isTwoPages) {
|
||||
int defacto = page * 2 + 1;
|
||||
String text = type.resolveKey(key + defacto, world);
|
||||
|
||||
if((this.page + 1) * 2 <= this.type.pages) { //TODO: change this to make it accurate for odd-numbered max pages
|
||||
setup.mainPage.renderText(key + defacto, fontRendererObj, guiLeft, guiTop, false);
|
||||
setup.mainPage.renderText(key + (defacto + 1), fontRendererObj, guiLeft, guiTop, true);
|
||||
if((page + 1) * 2 <= type.pages) { //Checks if text should be rendered as an aux or a main page
|
||||
mainPage.renderText(text, fontRendererObj, guiLeft, guiTop, false);
|
||||
|
||||
text = type.resolveKey(key + (defacto + 1), world); //kinda awkward, but no way around it
|
||||
mainPage.renderText(text, fontRendererObj, guiLeft, guiTop, true);
|
||||
} else
|
||||
setup.auxPage.renderText(key + defacto, fontRendererObj, guiLeft, guiTop, false);
|
||||
auxPage.renderText(text, fontRendererObj, guiLeft, guiTop, false);
|
||||
|
||||
} else {
|
||||
String text = type.resolveKey(key + (page + 1), world);
|
||||
|
||||
if(page < maxPage)
|
||||
setup.mainPage.renderText(key + (page + 1), fontRendererObj, guiLeft, guiTop, false);
|
||||
mainPage.renderText(text, fontRendererObj, guiLeft, guiTop, false);
|
||||
else
|
||||
setup.auxPage.renderText(key + (page + 1), fontRendererObj, guiLeft, guiTop, false);
|
||||
auxPage.renderText(text, fontRendererObj, guiLeft, guiTop, false);
|
||||
}
|
||||
|
||||
}
|
||||
@ -116,10 +129,10 @@ public class GUIBookLore extends GuiScreen {
|
||||
int q = 0; //if both buttons are somehow simultaneously clicked then obviously something's wrong already
|
||||
|
||||
if(page > 0)
|
||||
q = setup.button.handleInput(xSize, guiLeft, guiTop, false, i, j);
|
||||
q = button.handleInput(xSize, guiLeft, guiTop, false, i, j);
|
||||
|
||||
if(page < maxPage && q == 0)
|
||||
q = setup.button.handleInput(xSize, guiLeft, guiTop, true, i, j);
|
||||
q = button.handleInput(xSize, guiLeft, guiTop, true, i, j);
|
||||
|
||||
if(q != 0) {
|
||||
mc.getSoundHandler().playSound(PositionedSoundRecord.func_147674_a(new ResourceLocation("gui.button.press"), 1.0F));
|
||||
@ -138,13 +151,17 @@ public class GUIBookLore extends GuiScreen {
|
||||
public enum GUIAppearance {
|
||||
GUIDEBOOK(new GUIPage(272, 182, 20, 20, new ResourceLocation(RefStrings.MODID + ":textures/gui/book/book.png")).setScale(2F),
|
||||
new GUIPageButton(18, 10, 17, 148, new ResourceLocation(RefStrings.MODID + ":textures/gui/book/notebook_and_papers.png")).setUV(263, 0, 512, 512),
|
||||
0),
|
||||
LOOSEPAPER(new GUIPage(130, 165, 10, 24, new ResourceLocation(RefStrings.MODID + ":textures/gui/book/notebook_and_papers.png"), false).setScale(2F).setUV(133, 0),
|
||||
0), //Guide Book
|
||||
LOOSEPAPER(new GUIPage(130, 165, 10, 10, new ResourceLocation(RefStrings.MODID + ":textures/gui/book/notebook_and_papers.png"), false).setScale(1F).setUV(133, 0),
|
||||
new GUIPageButton(18, 10, 17, 148, new ResourceLocation(RefStrings.MODID + ":textures/gui/book/notebook_and_papers.png")).setUV(263, 0, 512, 512),
|
||||
1), //Singular loose page
|
||||
LOOSEPAPERS(new GUIPage(133, 165, 10, 24, new ResourceLocation(RefStrings.MODID + ":textures/gui/book/notebook_and_papers.png"), false).setScale(2F),
|
||||
LOOSEPAPERS(new GUIPage(133, 165, 10, 10, new ResourceLocation(RefStrings.MODID + ":textures/gui/book/notebook_and_papers.png"), false).setScale(1F),
|
||||
new GUIPageButton(18, 10, 17, 148, new ResourceLocation(RefStrings.MODID + ":textures/gui/book/notebook_and_papers.png")).setUV(263, 0, 512, 512),
|
||||
2);
|
||||
2), //Collection of loose pages
|
||||
NOTEBOOK(new GUIPage(133, 165, 10, 20, new ResourceLocation(RefStrings.MODID + ":textures/gui/book/notebook_and_papers.png"), false).setScale(1F).setUV(0, 165),
|
||||
new GUIPage(133, 165, 10, 20, new ResourceLocation(RefStrings.MODID + ":textures/gui/book/notebook_and_papers.png"), false).setScale(1F).setUV(133, 165),
|
||||
new GUIPageButton(18, 10, 17, 148, new ResourceLocation(RefStrings.MODID + ":textures/gui/book/notebook_and_papers.png")).setUV(263, 0, 512, 512),
|
||||
3);
|
||||
|
||||
public int itemTexture;
|
||||
|
||||
@ -184,6 +201,7 @@ public class GUIBookLore extends GuiScreen {
|
||||
protected int marginY; //Mirrored on both sides if two-sided.
|
||||
protected boolean isTwoPages = true;
|
||||
protected float scale = 1.0F;
|
||||
protected int spacing = 9; //12
|
||||
//TODO: split marginX into a left and right margin
|
||||
protected GUIPage(int x, int y, int marX, int marY, ResourceLocation texture, boolean twoPages) {
|
||||
this.sizeX = x;
|
||||
@ -213,8 +231,12 @@ public class GUIBookLore extends GuiScreen {
|
||||
return this;
|
||||
}
|
||||
|
||||
protected void renderText(String key, FontRenderer renderer, int left, int top, boolean secondPage) {
|
||||
String text = I18nUtil.resolveKey(key);
|
||||
protected GUIPage setSpacing(int spacing) {
|
||||
this.spacing = spacing;
|
||||
return this;
|
||||
}
|
||||
|
||||
protected void renderText(String text, FontRenderer renderer, int left, int top, boolean secondPage) {
|
||||
int width = isTwoPages ? (sizeX / 2) - (marginX * 2) : sizeX - (marginX * 2);
|
||||
int widthScaled = (int) (width * scale);
|
||||
|
||||
@ -243,7 +265,7 @@ public class GUIBookLore extends GuiScreen {
|
||||
int sideOffset = secondPage ? sizeX - marginX - width : marginX;
|
||||
|
||||
for(int l = 0; l < lines.size(); l++) {
|
||||
renderer.drawString(lines.get(l), (int)((left + sideOffset) * scale), (int)((top + marginY) * scale + (12 * l)), 4210752);
|
||||
renderer.drawString(lines.get(l), (int)((left + sideOffset) * scale), (int)((top + marginY) * scale + (spacing * l)), 4210752);
|
||||
}
|
||||
|
||||
GL11.glPopMatrix();
|
||||
|
||||
@ -4,11 +4,13 @@ import java.util.List;
|
||||
|
||||
import com.hbm.inventory.gui.GUIBookLore;
|
||||
import com.hbm.inventory.gui.GUIBookLore.GUIAppearance;
|
||||
import com.hbm.items.ModItems;
|
||||
import com.hbm.items.tool.ItemGuideBook.BookType;
|
||||
import com.hbm.lib.RefStrings;
|
||||
import com.hbm.main.MainRegistry;
|
||||
import com.hbm.tileentity.IGUIProvider;
|
||||
import com.hbm.util.I18nUtil;
|
||||
import com.hbm.world.generator.room.TestDungeonRoom8;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
@ -64,7 +66,7 @@ public class ItemBookLore extends Item implements IGUIProvider {
|
||||
|
||||
protected IIcon[] icons;
|
||||
|
||||
public final static String[] itemTextures = new String[] { ":book_guide", ":paper_loose", ":papers_loose" };
|
||||
public final static String[] itemTextures = new String[] { ":book_guide", ":paper_loose", ":papers_loose", ":notebook" };
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerIcons(IIconRegister reg) {
|
||||
@ -99,9 +101,12 @@ public class ItemBookLore extends Item implements IGUIProvider {
|
||||
}
|
||||
|
||||
public enum BookLoreType {
|
||||
TEST(true, "test", 5, GUIAppearance.GUIDEBOOK),
|
||||
REL_RAMBLINGS("rel_ramblings", 3, GUIAppearance.LOOSEPAPERS);
|
||||
|
||||
TEST(true, "test", 5, GUIAppearance.NOTEBOOK),
|
||||
BOOK_IODINE(true, "book_iodine", 3, GUIAppearance.LOOSEPAPERS) {
|
||||
public String resolveKey(String key, World world) {
|
||||
int slot = TestDungeonRoom8.getSlot(world, ModItems.powder_iodine);
|
||||
return I18nUtil.resolveKey(key, slot); }}
|
||||
;
|
||||
|
||||
//Why? it's quite simple; i am too burnt out and also doing it the other way
|
||||
//is too inflexible for my taste
|
||||
@ -124,7 +129,6 @@ public class ItemBookLore extends Item implements IGUIProvider {
|
||||
this.appearance = appearance;
|
||||
}
|
||||
|
||||
//TODO: actually shove this into the gui
|
||||
/** Function to resolve I18n keys using potential save-dependent information, a la format specifiers. */
|
||||
public String resolveKey(String key, World world) {
|
||||
return I18nUtil.resolveKey(key);
|
||||
|
||||
@ -37,7 +37,7 @@ public class ItemWandD extends Item {
|
||||
if(pos != null) {
|
||||
|
||||
ItemStack itemStack = new ItemStack(ModItems.book_lore);
|
||||
BookLoreType.setTypeForStack(itemStack, BookLoreType.REL_RAMBLINGS);
|
||||
BookLoreType.setTypeForStack(itemStack, BookLoreType.BOOK_IODINE);
|
||||
|
||||
player.inventory.addItemStackToInventory(itemStack);
|
||||
player.inventoryContainer.detectAndSendChanges();
|
||||
|
||||
@ -323,6 +323,12 @@ book_lore.test.page.3=3
|
||||
book_lore.test.page.4=4
|
||||
book_lore.test.page.5=5
|
||||
|
||||
book_lore.book_iodine.name=Note
|
||||
book_lore.book_iodine.author=Dave
|
||||
book_lore.book_iodine.page.1=alright you will not believe this, but old man weathervane finally managed to show up again since he left two weeks ago and what's more surprising is the fact that he actually decided to spill the beans on what they were doing in the canyon:
|
||||
book_lore.book_iodine.page.2=apparently the morons from R&D discovered a compound that is mostly inorganic, pretty much like a toxin in nature, but get this: the dying cells will reproduce said toxin and excrete it through the skin, creating an aerosol that is highly contagious.
|
||||
book_lore.book_iodine.page.3=it's just like a virus, but not a virus. the composition is weird, you can mix it in any household bottle but you do have to get the order right. the doc told me that the first ingredient which is just powdered iodine crystals goes into slot %d
|
||||
|
||||
cannery.f1=[ Press F1 for help ]
|
||||
|
||||
cannery.centrifuge=Gas Centrifuge
|
||||
|
||||
BIN
src/main/resources/assets/hbm/textures/items/notebook.png
Normal file
BIN
src/main/resources/assets/hbm/textures/items/notebook.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 265 B |
Loading…
x
Reference in New Issue
Block a user