use of net.minecraftforge.client.gui.widget.ModListWidget in project MinecraftForge by MinecraftForge.
the class ModListScreen method init.
@Override
public void init() {
for (IModInfo mod : mods) {
listWidth = Math.max(listWidth, getFontRenderer().width(mod.getDisplayName()) + 10);
listWidth = Math.max(listWidth, getFontRenderer().width(MavenVersionStringHelper.artifactVersionToString(mod.getVersion())) + 5);
}
listWidth = Math.max(Math.min(listWidth, width / 3), 100);
listWidth += listWidth % numButtons != 0 ? (numButtons - listWidth % numButtons) : 0;
int modInfoWidth = this.width - this.listWidth - (PADDING * 3);
int doneButtonWidth = Math.min(modInfoWidth, 200);
int y = this.height - 20 - PADDING;
int fullButtonHeight = PADDING + 20 + PADDING;
doneButton = new Button(((listWidth + PADDING + this.width - doneButtonWidth) / 2), y, doneButtonWidth, 20, new TranslatableComponent("gui.done"), b -> ModListScreen.this.onClose());
openModsFolderButton = new Button(6, y, this.listWidth, 20, new TranslatableComponent("fml.menu.mods.openmodsfolder"), b -> Util.getPlatform().openFile(FMLPaths.MODSDIR.get().toFile()));
y -= 20 + PADDING;
configButton = new Button(6, y, this.listWidth, 20, new TranslatableComponent("fml.menu.mods.config"), b -> ModListScreen.this.displayModConfig());
y -= 14 + PADDING;
search = new EditBox(getFontRenderer(), PADDING + 1, y, listWidth - 2, 14, new TranslatableComponent("fml.menu.mods.search"));
this.modList = new ModListWidget(this, listWidth, fullButtonHeight, search.y - getFontRenderer().lineHeight - PADDING);
this.modList.setLeftPos(6);
this.modInfo = new InfoPanel(this.minecraft, modInfoWidth, this.height - PADDING - fullButtonHeight, PADDING);
this.addRenderableWidget(modList);
this.addRenderableWidget(modInfo);
this.addRenderableWidget(search);
this.addRenderableWidget(doneButton);
this.addRenderableWidget(configButton);
this.addRenderableWidget(openModsFolderButton);
search.setFocus(false);
search.setCanLoseFocus(true);
configButton.active = false;
final int width = listWidth / numButtons;
int x = PADDING;
addRenderableWidget(SortType.NORMAL.button = new Button(x, PADDING, width - buttonMargin, 20, SortType.NORMAL.getButtonText(), b -> resortMods(SortType.NORMAL)));
x += width + buttonMargin;
addRenderableWidget(SortType.A_TO_Z.button = new Button(x, PADDING, width - buttonMargin, 20, SortType.A_TO_Z.getButtonText(), b -> resortMods(SortType.A_TO_Z)));
x += width + buttonMargin;
addRenderableWidget(SortType.Z_TO_A.button = new Button(x, PADDING, width - buttonMargin, 20, SortType.Z_TO_A.getButtonText(), b -> resortMods(SortType.Z_TO_A)));
resortMods(SortType.NORMAL);
updateCache();
}
Aggregations