mirror of
https://github.com/Ellpeck/ActuallyAdditions.git
synced 2024-11-22 15:18:34 +01:00
Added display tips to the booklet
This commit is contained in:
parent
931eba4cc4
commit
05322f1392
5 changed files with 36 additions and 10 deletions
|
@ -21,6 +21,8 @@ import net.minecraft.client.Minecraft;
|
|||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.text.TextFormatting;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
@ -65,6 +67,7 @@ public class BookletEntry implements IBookletEntry{
|
|||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public List<IBookletChapter> getChaptersForDisplay(String searchBarText){
|
||||
if(searchBarText != null && !searchBarText.isEmpty()){
|
||||
String search = searchBarText.toLowerCase(Locale.ROOT);
|
||||
|
@ -91,6 +94,7 @@ public class BookletEntry implements IBookletEntry{
|
|||
}
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
private static boolean fitsFilter(IBookletPage page, String searchBarText){
|
||||
Minecraft mc = Minecraft.getMinecraft();
|
||||
|
||||
|
|
|
@ -30,6 +30,7 @@ public class GuiEntry extends GuiBooklet{
|
|||
|
||||
//The page in the entry. Say you have 2 more chapters than fit on one double page, then those 2 would be displayed on entryPage 1 instead.
|
||||
private final int entryPage;
|
||||
private final int pageAmount;
|
||||
private final IBookletEntry entry;
|
||||
private final List<IBookletChapter> chapters;
|
||||
private final String searchText;
|
||||
|
@ -42,6 +43,9 @@ public class GuiEntry extends GuiBooklet{
|
|||
this.searchText = search;
|
||||
this.focusSearch = focusSearch;
|
||||
this.chapters = entry.getChaptersForDisplay(search);
|
||||
|
||||
IBookletChapter lastChap = this.chapters.get(this.chapters.size()-1);
|
||||
this.pageAmount = lastChap == null ? 1 : calcEntryPage(this.entry, lastChap, this.searchText)+1;
|
||||
}
|
||||
|
||||
public GuiEntry(GuiScreen previousScreen, GuiBookletBase parentPage, IBookletEntry entry, IBookletChapter chapterForPageCalc, String search, boolean focusSearch){
|
||||
|
@ -53,6 +57,19 @@ public class GuiEntry extends GuiBooklet{
|
|||
return index/(BUTTONS_PER_PAGE*2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawScreenPre(int mouseX, int mouseY, float partialTicks){
|
||||
super.drawScreenPre(mouseX, mouseY, partialTicks);
|
||||
|
||||
String name = this.entry.getLocalizedName();
|
||||
this.fontRendererObj.drawString(name, this.guiLeft+this.xSize/2-this.fontRendererObj.getStringWidth(name)/2, this.guiTop-1, 0xFFFFFF, true);
|
||||
|
||||
for(int i = 0; i < 2; i++){
|
||||
String pageStrg = "Page "+(this.entryPage*2+i+1)+"/"+this.pageAmount*2;
|
||||
this.renderScaledAsciiString(pageStrg, this.guiLeft+25+i*136, this.guiTop+this.ySize-7, 0xFFFFFF, false, 0.8F);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initGui(){
|
||||
super.initGui();
|
||||
|
@ -116,14 +133,7 @@ public class GuiEntry extends GuiBooklet{
|
|||
|
||||
@Override
|
||||
public boolean hasPageRightButton(){
|
||||
if(!this.chapters.isEmpty()){
|
||||
IBookletChapter lastChap = this.chapters.get(this.chapters.size()-1);
|
||||
if(lastChap != null){
|
||||
int lastPage = calcEntryPage(this.entry, lastChap, this.searchText);
|
||||
return this.entryPage < lastPage;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
return !this.chapters.isEmpty() && this.entryPage < this.pageAmount-1;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -119,9 +119,19 @@ public class GuiPage extends GuiBooklet{
|
|||
public void drawScreenPre(int mouseX, int mouseY, float partialTicks){
|
||||
super.drawScreenPre(mouseX, mouseY, partialTicks);
|
||||
|
||||
if(this.pages[0] != null){
|
||||
IBookletChapter chapter = this.pages[0].getChapter();
|
||||
String name = chapter.getLocalizedName();
|
||||
this.fontRendererObj.drawString(name, this.guiLeft+this.xSize/2-this.fontRendererObj.getStringWidth(name)/2, this.guiTop-1, 0xFFFFFF, true);
|
||||
}
|
||||
|
||||
for(int i = 0; i < this.pages.length; i++){
|
||||
IBookletPage page = this.pages[i];
|
||||
if(page != null){
|
||||
IBookletChapter chapter = this.pages[i].getChapter();
|
||||
String pageStrg = "Page "+(chapter.getPageIndex(this.pages[i])+1)+"/"+chapter.getAllPages().length;
|
||||
this.renderScaledAsciiString(pageStrg, this.guiLeft+25+i*136, this.guiTop+this.ySize-7, 0xFFFFFF, false, 0.8F);
|
||||
|
||||
GlStateManager.color(1F, 1F, 1F);
|
||||
page.drawScreenPre(this, this.guiLeft+6+i*142, this.guiTop+7, mouseX, mouseY, partialTicks);
|
||||
}
|
||||
|
|
|
@ -20,6 +20,8 @@ import de.ellpeck.actuallyadditions.mod.booklet.gui.GuiPage;
|
|||
import de.ellpeck.actuallyadditions.mod.util.ItemUtil;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
@ -41,6 +43,7 @@ public final class BookletUtils{
|
|||
return null;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public static GuiPage createBookletGuiFromPage(GuiScreen previousScreen, IBookletPage page){
|
||||
GuiMainPage mainPage = new GuiMainPage(previousScreen);
|
||||
|
||||
|
@ -50,6 +53,7 @@ public final class BookletUtils{
|
|||
return createPageGui(previousScreen, entry, page);
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public static GuiPage createPageGui(GuiScreen previousScreen, GuiBookletBase parentPage, IBookletPage page){
|
||||
IBookletChapter chapter = page.getChapter();
|
||||
|
||||
|
|
|
@ -116,7 +116,6 @@ public final class PacketHandler{
|
|||
};
|
||||
public static final IDataHandler CHANGE_PLAYER_DATA_HANDLER = new IDataHandler(){
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void handleData(NBTTagCompound compound){
|
||||
NBTTagCompound data = compound.getCompoundTag("Data");
|
||||
UUID id = compound.getUniqueId("UUID");
|
||||
|
@ -127,7 +126,6 @@ public final class PacketHandler{
|
|||
}
|
||||
};
|
||||
|
||||
|
||||
public static void init(){
|
||||
theNetwork = NetworkRegistry.INSTANCE.newSimpleChannel(ModUtil.MOD_ID);
|
||||
theNetwork.registerMessage(PacketServerToClient.Handler.class, PacketServerToClient.class, 0, Side.CLIENT);
|
||||
|
|
Loading…
Reference in a new issue