use of net.minecraftforge.fml.client.gui.widget.ModListWidget in project Magma-1.16.x by magmafoundation.
the class ModListScreen method init.
@Override
public void init() {
for (ModInfo 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;
this.addButton(new Button(((listWidth + PADDING + this.width - doneButtonWidth) / 2), y, doneButtonWidth, 20, new TranslationTextComponent("gui.done"), b -> ModListScreen.this.onClose()));
this.addButton(this.openModsFolderButton = new Button(6, y, this.listWidth, 20, new TranslationTextComponent("fml.menu.mods.openmodsfolder"), b -> Util.getPlatform().openFile(FMLPaths.MODSDIR.get().toFile())));
y -= 20 + PADDING;
this.addButton(this.configButton = new Button(6, y, this.listWidth, 20, new TranslationTextComponent("fml.menu.mods.config"), b -> ModListScreen.this.displayModConfig()));
this.configButton.active = false;
y -= 14 + PADDING + 1;
search = new TextFieldWidget(getFontRenderer(), PADDING + 1, y, listWidth - 2, 14, new TranslationTextComponent("fml.menu.mods.search"));
int fullButtonHeight = PADDING + 20 + PADDING;
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);
children.add(search);
children.add(modList);
children.add(modInfo);
search.setFocus(false);
search.setCanLoseFocus(true);
final int width = listWidth / numButtons;
int x = PADDING;
addButton(SortType.NORMAL.button = new Button(x, PADDING, width - buttonMargin, 20, SortType.NORMAL.getButtonText(), b -> resortMods(SortType.NORMAL)));
x += width + buttonMargin;
addButton(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;
addButton(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();
}
use of net.minecraftforge.fml.client.gui.widget.ModListWidget in project LoliServer by Loli-Server.
the class ModListScreen method init.
@Override
public void init() {
for (ModInfo 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;
this.addButton(new Button(((listWidth + PADDING + this.width - doneButtonWidth) / 2), y, doneButtonWidth, 20, new TranslationTextComponent("gui.done"), b -> ModListScreen.this.onClose()));
this.addButton(this.openModsFolderButton = new Button(6, y, this.listWidth, 20, new TranslationTextComponent("fml.menu.mods.openmodsfolder"), b -> Util.getPlatform().openFile(FMLPaths.MODSDIR.get().toFile())));
y -= 20 + PADDING;
this.addButton(this.configButton = new Button(6, y, this.listWidth, 20, new TranslationTextComponent("fml.menu.mods.config"), b -> ModListScreen.this.displayModConfig()));
this.configButton.active = false;
y -= 14 + PADDING + 1;
search = new TextFieldWidget(getFontRenderer(), PADDING + 1, y, listWidth - 2, 14, new TranslationTextComponent("fml.menu.mods.search"));
int fullButtonHeight = PADDING + 20 + PADDING;
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);
children.add(search);
children.add(modList);
children.add(modInfo);
search.setFocus(false);
search.setCanLoseFocus(true);
final int width = listWidth / numButtons;
int x = PADDING;
addButton(SortType.NORMAL.button = new Button(x, PADDING, width - buttonMargin, 20, SortType.NORMAL.getButtonText(), b -> resortMods(SortType.NORMAL)));
x += width + buttonMargin;
addButton(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;
addButton(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