Search in sources :

Example 1 with PageData

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);
    }
}
Also used : PageContent(slimeknights.mantle.client.book.data.content.PageContent) PageData(slimeknights.mantle.client.book.data.PageData) ContentListing(slimeknights.tconstruct.library.book.content.ContentListing) ContentModifier(slimeknights.tconstruct.library.book.content.ContentModifier) SectionData(slimeknights.mantle.client.book.data.SectionData) IModifier(slimeknights.tconstruct.library.modifiers.IModifier)

Example 2 with PageData

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;
}
Also used : PageData(slimeknights.mantle.client.book.data.PageData)

Example 3 with PageData

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();
        }
    }
}
Also used : ItemElement(slimeknights.mantle.client.screen.book.element.ItemElement) IMaterial(slimeknights.tconstruct.library.materials.definition.IMaterial) ContentPageIconList(slimeknights.tconstruct.library.client.book.content.ContentPageIconList) MaterialId(slimeknights.tconstruct.library.materials.definition.MaterialId) PageData(slimeknights.mantle.client.book.data.PageData) SizedBookElement(slimeknights.mantle.client.screen.book.element.SizedBookElement) ContentMaterial(slimeknights.tconstruct.library.client.book.content.ContentMaterial)

Aggregations

PageData (slimeknights.mantle.client.book.data.PageData)3 SectionData (slimeknights.mantle.client.book.data.SectionData)1 PageContent (slimeknights.mantle.client.book.data.content.PageContent)1 ItemElement (slimeknights.mantle.client.screen.book.element.ItemElement)1 SizedBookElement (slimeknights.mantle.client.screen.book.element.SizedBookElement)1 ContentListing (slimeknights.tconstruct.library.book.content.ContentListing)1 ContentModifier (slimeknights.tconstruct.library.book.content.ContentModifier)1 ContentMaterial (slimeknights.tconstruct.library.client.book.content.ContentMaterial)1 ContentPageIconList (slimeknights.tconstruct.library.client.book.content.ContentPageIconList)1 IMaterial (slimeknights.tconstruct.library.materials.definition.IMaterial)1 MaterialId (slimeknights.tconstruct.library.materials.definition.MaterialId)1 IModifier (slimeknights.tconstruct.library.modifiers.IModifier)1