use of slimeknights.mantle.client.book.data.PageData in project EnderIO by SleepyTrousers.
the class OurBookTransformer method transform.
@Override
public void transform(BookData book) {
SectionData section1 = null, section2 = null;
for (SectionData section : book.sections) {
if (section.name.equals("modifiers")) {
section1 = section;
}
if (section.name.equals("eiomodifiers")) {
section2 = section;
}
}
if (section1 != null && section2 != null) {
for (PageData page : section2.pages) {
page.parent = section1;
section1.pages.add(page);
}
PageData pageData = section1.pages.get(0);
PageContent content = pageData.content;
if (content instanceof ContentListing) {
ContentListing listing = (ContentListing) content;
for (PageData page : section2.pages) {
page.parent = section1;
if (page.content instanceof ContentModifier) {
IModifier modifier = TinkerRegistry.getModifier(((ContentModifier) page.content).modifierName);
if (modifier != null) {
page.name = "page-eio-" + modifier.getIdentifier();
listing.addEntry(modifier.getLocalizedName(), page);
}
}
}
}
section2.pages.clear();
book.sections.remove(section2);
}
}
use of slimeknights.mantle.client.book.data.PageData in project TinkersConstruct by SlimeKnights.
the class ContentPageIconList method getPagesNeededForItemCount.
public static List<ContentPageIconList> getPagesNeededForItemCount(int count, SectionData data, String title, String subText) {
List<ContentPageIconList> listPages = Lists.newArrayList();
while (count > 0) {
ContentPageIconList overview = new ContentPageIconList();
PageData page = new PageData(true);
page.source = data.source;
page.parent = data;
page.content = overview;
page.load();
data.pages.add(page);
overview.title = title;
overview.subText = subText;
listPages.add(overview);
count -= overview.getMaxIconCount();
}
// ensure same size for all
if (listPages.size() > 1) {
listPages.forEach(page -> page.maxScale = 1f);
}
return listPages;
}
use of slimeknights.mantle.client.book.data.PageData in project TinkersConstruct by SlimeKnights.
the class AbstractMaterialSectionTransformer method transform.
@Override
public void transform(BookData book, SectionData sectionData) {
sectionData.source = BookRepository.DUMMY;
sectionData.parent = book;
List<IMaterial> materialList = MaterialRegistry.getMaterials().stream().filter(this::isValidMaterial).toList();
if (materialList.isEmpty()) {
return;
}
// calculate pages needed
List<ContentPageIconList> listPages = ContentPageIconList.getPagesNeededForItemCount(materialList.size(), sectionData, book.translate(this.sectionName), book.strings.get(String.format("%s.subtext", this.sectionName)));
ListIterator<ContentPageIconList> iter = listPages.listIterator();
ContentPageIconList overview = iter.next();
for (IMaterial material : materialList) {
MaterialId materialId = material.getIdentifier();
ContentMaterial contentMaterial = this.getPageContent(materialId);
PageData page = this.addPage(sectionData, materialId.toString(), ContentMaterial.ID, contentMaterial);
SizedBookElement icon = new ItemElement(0, 0, 1f, contentMaterial.getDisplayStacks());
while (!overview.addLink(icon, contentMaterial.getTitleComponent(), page)) {
overview = iter.next();
}
}
}
Aggregations