Skip to content

Commit

Permalink
more index wrapping fixes (i am trying very hard to fake-smile rn)
Browse files Browse the repository at this point in the history
  • Loading branch information
gliscowo committed Nov 3, 2024
1 parent 1d982dd commit 3205f28
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ org.gradle.jvmargs=-Xmx1G
loader_version=0.15.11

# Mod Properties
mod_version = 0.1.13
mod_version = 0.1.14
maven_group = io.wispforest
archives_base_name = lavender

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -752,11 +752,12 @@ public LandingPageSupplier(LavenderBookScreen context) {
var indexPage = Containers.verticalFlow(Sizing.fill(100), Sizing.content());
this.pages.add(indexPage);

var rootCategories = book.categories().stream().filter(category -> category.parent() == null).toList();
if (!book.categories().isEmpty()) {
var categories = this.pageWithHeader(Text.translatable("text.lavender.categories"));
categories.verticalSizing(Sizing.content());

var categoryContainer = this.buildCategoryIndex(book.categories().stream().filter(category -> category.parent() == null));
var categoryContainer = this.buildCategoryIndex(rootCategories.stream());
categories.child(categoryContainer);

categoryContainer.child(Components.item(LavenderBookItem.itemOf(this.context.book)).<ItemComponent>configure(categoryButton -> {
Expand All @@ -783,7 +784,7 @@ public LandingPageSupplier(LavenderBookScreen context) {
);

int entriesOnCategoryPage = !book.categories().isEmpty()
? 150 - 36 - MathHelper.ceilDiv(book.categories().size() - 1, 4) * 24
? 150 - 36 - MathHelper.ceilDiv(rootCategories.size() + 1, 4) * 24
: 150;

var orphanedEntries = this.buildEntryIndex(book.orphanedEntries(), true, entriesOnCategoryPage);
Expand Down Expand Up @@ -914,13 +915,13 @@ public CategoryPageSupplier(LavenderBookScreen context, Category category) {
// --- category & entry index ---

var categoryContainer = this.buildCategoryIndex(this.context.book.categories().stream().filter(category_ -> Objects.equals(category_.parent(), category.id())));
int entriesOnCategoryPage = !categoryContainer.children().isEmpty()
int spaceOnCategoryPage = !categoryContainer.children().isEmpty()
? 125 - 15 - MathHelper.ceilDiv(categoryContainer.children().size(), 4) * 24
: 125;

var entries = this.context.book.entriesByCategory(this.category);
if (entries != null) {
var indexPages = this.buildEntryIndex(entries, true, entriesOnCategoryPage);
var indexPages = this.buildEntryIndex(entries, true, spaceOnCategoryPage);
for (int i = 0; i < indexPages.size(); i++) {
var page = i == 0
? this.pageWithHeader(Text.translatable("text.lavender.index")).child(indexPages.get(0))
Expand Down

0 comments on commit 3205f28

Please sign in to comment.