Skip to content
This repository was archived by the owner on Dec 30, 2022. It is now read-only.

Commit 1f5cc7d

Browse files
committed
Improved paging
Added nexus (my private instance) Signed-off-by: DeathsGun <deathsgun@protonmail.com>
1 parent 4abb6b3 commit 1f5cc7d

6 files changed

Lines changed: 29 additions & 8 deletions

File tree

build.gradle

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
//file:noinspection GroovyAssignabilityCheck
2+
//file:noinspection GroovyAccessibility
13
plugins {
24
id "fabric-loom" version "0.8-SNAPSHOT"
35
id "maven-publish"
@@ -80,6 +82,13 @@ publishing {
8082
}
8183

8284
repositories {
83-
mavenLocal()
85+
maven {
86+
url = "http://vault:8081/repository/maven-snapshots/"
87+
allowInsecureProtocol true
88+
credentials {
89+
username "buildtool"
90+
password project.buildtools_pw
91+
}
92+
}
8493
}
8594
}

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ minecraft_version=1.17
2222
yarn_mappings=1.17+build.6
2323
loader_version=0.11.3
2424
# Mod Properties
25-
mod_version=1.0.0
25+
mod_version=1.0.0-SNAPSHOT
2626
maven_group=xyz.deathsgun
2727
archives_base_name=modmanager
2828
# Dependencies

settings.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,4 @@ pluginManagement {
2323
gradlePluginPortal()
2424
}
2525
}
26+
rootProject.name = "modmanager"

src/main/java/xyz/deathsgun/modmanager/gui/ModsOverviewScreen.java

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,8 @@
2020
import net.minecraft.client.gui.screen.Screen;
2121
import net.minecraft.client.gui.widget.ButtonWidget;
2222
import net.minecraft.client.gui.widget.TextFieldWidget;
23-
import net.minecraft.client.input.KeyboardInput;
2423
import net.minecraft.client.util.math.MatrixStack;
2524
import net.minecraft.text.TranslatableText;
26-
import org.apache.logging.log4j.LogManager;
27-
import org.apache.logging.log4j.Logger;
2825
import xyz.deathsgun.modmanager.gui.widget.CategoryListEntry;
2926
import xyz.deathsgun.modmanager.gui.widget.CategoryListWidget;
3027
import xyz.deathsgun.modmanager.gui.widget.ModListEntry;
@@ -43,6 +40,8 @@ public class ModsOverviewScreen extends Screen implements IListScreen {
4340
private TextFieldWidget searchBox;
4441
private int paneWidth;
4542
private int rightPaneX;
43+
private ButtonWidget previousPage;
44+
private ButtonWidget nextPage;
4645

4746
public ModsOverviewScreen(Screen previousScreen) {
4847
super(new TranslatableText("modmanager.title"));
@@ -67,9 +66,9 @@ protected void init() {
6766
this.categoryListWidget.init();
6867
this.modListWidget.init();
6968

70-
this.addDrawableChild(new ButtonWidget(rightPaneX, this.height - 30, modListWidth / 2 - 10, 20,
69+
this.previousPage = this.addDrawableChild(new ButtonWidget(rightPaneX, this.height - 30, modListWidth / 2 - 10, 20,
7170
new TranslatableText("modmanager.page.previous"), button -> this.modListWidget.showPreviousPage()));
72-
this.addDrawableChild(new ButtonWidget(rightPaneX + modListWidth / 2, this.height - 30, modListWidth / 2, 20,
71+
this.nextPage = this.addDrawableChild(new ButtonWidget(rightPaneX + modListWidth / 2, this.height - 30, modListWidth / 2, 20,
7372
new TranslatableText("modmanager.page.next"), button -> this.modListWidget.showNextPage()));
7473
}
7574

@@ -91,6 +90,7 @@ public void render(MatrixStack matrices, int mouseX, int mouseY, float delta) {
9190
@Override
9291
public void tick() {
9392
this.searchBox.tick();
93+
this.nextPage.active = this.modListWidget.getEntryCount() >= this.modListWidget.getLimit();
9494
}
9595

9696
@Override
@@ -116,7 +116,9 @@ public <E> void updateSelectedEntry(Object widget, E entry) {
116116
Objects.requireNonNull(this.client).openScreen(new ModDetailScreen(this, ((ModListEntry) entry).getMod()));
117117
return;
118118
}
119-
this.selectedMod = (ModListEntry) entry;
119+
if (entry instanceof ModListEntry) {
120+
this.selectedMod = (ModListEntry) entry;
121+
}
120122
}
121123
}
122124
}

src/main/java/xyz/deathsgun/modmanager/gui/widget/ModListWidget.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,11 +68,16 @@ public void searchMods(String query) {
6868
this.category = null;
6969
ModManager.getModProvider().getMods(query, page, limit)
7070
.forEach(mod -> this.addEntry(new ModListEntry(this, mod)));
71+
this.query = query;
7172
} catch (Exception e) {
7273
e.printStackTrace();
7374
}
7475
}
7576

77+
public int getLimit() {
78+
return limit;
79+
}
80+
7681
private void clearMods() {
7782
this.mods.clear();
7883
for (int i = 0; i < this.getEntryCount(); i++) {

src/main/java/xyz/deathsgun/modmanager/gui/widget/better/BetterListWidget.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,10 @@ public boolean isSelectedEntry(BetterListEntry<E> entry) {
185185
}
186186

187187

188+
public int getEntryCount() {
189+
return super.getEntryCount();
190+
}
191+
188192
public static abstract class BetterListEntry<E extends BetterListWidget.BetterListEntry<E>> extends AlwaysSelectedEntryListWidget.Entry<E> {
189193

190194
protected final BetterListWidget<E> list;

0 commit comments

Comments
 (0)