use of net.minecraft.client.gui.widget.ButtonWidget in project BlockMeter by ModProg.
the class SelectBoxGui method init.
@Override
protected void init() {
final int uiHeight = (boxes.length + 1) * (BUTTONHEIGHT + PADDING);
for (int i = 0; i < boxes.length; i++) {
final ClientMeasureBox box = boxes[i];
final TranslatableText text = new TranslatableText("blockmeter.boxToString", new Object[] { box.getBlockStart().getX(), box.getBlockStart().getY(), box.getBlockStart().getZ(), box.getBlockEnd().getX(), box.getBlockEnd().getY(), box.getBlockEnd().getZ() });
// text.setStyle(text.getStyle().withColor(TextColor.fromRgb(box.getColor().getSignColor())));
this.addDrawableChild(new ColorButton(this.width / 2 - (BUTTONWIDTH) / 2, this.height / 2 - uiHeight / 2 + i * (BUTTONHEIGHT + PADDING), BUTTONWIDTH, BUTTONHEIGHT, text, box.getColor().getColorComponents(), false, true, button -> {
box.loosenCorner(block);
MinecraftClient.getInstance().setScreen((Screen) null);
}));
}
this.addDrawableChild(new ButtonWidget(this.width / 2 - BUTTONWIDTH / 2, this.height / 2 - uiHeight / 2 + boxes.length * (BUTTONHEIGHT + PADDING) + PADDING, BUTTONWIDTH, BUTTONHEIGHT, new TranslatableText("gui.cancel"), button -> {
MinecraftClient.getInstance().setScreen((Screen) null);
}));
}
use of net.minecraft.client.gui.widget.ButtonWidget in project RPG-Hud by KurodaAkira.
the class GuiSettingsMod method init.
@Override
public void init() {
TextRenderer fontRenderer = client.textRenderer;
if (this.subSetting.equals("")) {
GuiButtonTooltip guismallbutton = new GuiButtonTooltip(this.width / 2 - 155 + 0 % 2 * 160, this.height / 6 - 14 + 20 * (0 >> 1), "general", new TranslatableText("gui.rpg.general"), button -> {
GuiButtonTooltip b = (GuiButtonTooltip) button;
if (b.enumOptions != null)
client.setScreen(new GuiSettingsMod(instance, b.enumOptions, new TranslatableText("gui.settings.rpghud")));
}).setTooltip(I18n.translate("tooltip.general", new Object[0]));
this.addDrawableChild(guismallbutton);
int count = 1;
for (HudElementType type : HudElementType.values()) {
List<String> settings = this.settings.getSettingsOf(type);
if (!settings.isEmpty()) {
guismallbutton = new GuiButtonTooltip(this.width / 2 - 155 + count % 2 * 160, this.height / 6 - 14 + 20 * (count >> 1), type.name(), new TranslatableText(type.getDisplayName()), button -> {
GuiButtonTooltip b = (GuiButtonTooltip) button;
if (b.enumOptions != null) {
this.client.setScreen(new GuiSettingsMod(instance, b.enumOptions, new TranslatableText("gui.settings.rpghud")));
}
}).setTooltip(I18n.translate("tooltip.element", new Object[0]));
this.addDrawableChild(guismallbutton);
count++;
}
}
} else {
List<String> settingList = this.settings.getSettingsOf(this.subSetting);
for (int i = 0; i < settingList.size(); i++) {
if (this.settings.getSetting(settingList.get(i)) instanceof SettingPosition) {
String[] values = ((String) this.settings.getSetting(settingList.get(i)).getValue()).split("_");
List<TextFieldWidget> fields = new ArrayList<TextFieldWidget>();
GuiTextLabel settingLabel = new GuiTextLabel(this.width / 2 - 152 + i % 2 * 160, this.height / 6 - 8 + 20 * (i >> 1), this.settings.getButtonString(settingList.get(i)));
labelList.add(settingLabel);
TextFieldWidget xPos = new TextFieldWidgetMod(fontRenderer, ValueType.POSITION, this.width / 2 - 100 + i % 2 * 160, this.height / 6 - 12 + 20 * (i >> 1), 45, 15, new TranslatableText(values[0]));
xPos.setText(values[0]);
xPos.setMaxLength(6);
this.addDrawableChild(xPos);
fields.add(xPos);
TextFieldWidget yPos = new TextFieldWidgetMod(fontRenderer, ValueType.POSITION, this.width / 2 - 100 + i % 2 * 160 + 48, this.height / 6 - 12 + 20 * (i >> 1), 45, 15, new TranslatableText(values[1]));
yPos.setText(values[1]);
yPos.setMaxLength(6);
this.addDrawableChild(yPos);
fields.add(yPos);
textFields.put(settingList.get(i), fields);
} else if (this.settings.getSetting(settingList.get(i)) instanceof SettingDouble) {
List<TextFieldWidget> fields = new ArrayList<TextFieldWidget>();
GuiTextLabel scaleLabel = new GuiTextLabel(this.width / 2 - 151 + i % 2 * 160, this.height / 6 - 8 + 20 * (i >> 1), this.settings.getButtonString(settingList.get(i)));
TextFieldWidget scale = new TextFieldWidgetMod(fontRenderer, ValueType.DOUBLE, this.width / 2 - 100 + i % 2 * 160 + 3, this.height / 6 - 12 + 20 * (i >> 1), 90, 15, new TranslatableText(String.valueOf(this.settings.getDoubleValue(settingList.get(i)))));
scale.setText(String.valueOf(this.settings.getDoubleValue(settingList.get(i))));
labelList.add(scaleLabel);
this.addDrawableChild(scale);
fields.add(scale);
textFields.put(settingList.get(i), fields);
} else {
GuiButtonTooltip guismallbutton = new GuiButtonTooltip(this.width / 2 - 155 + i % 2 * 160, this.height / 6 - 14 + 20 * (i >> 1), settingList.get(i), new TranslatableText(this.settings.getButtonString(settingList.get(i))), button -> {
GuiButtonTooltip b = (GuiButtonTooltip) button;
if (b.enumOptions != null) {
if (settings.getSetting(b.enumOptions) instanceof SettingColor) {
client.setScreen(new GuiSettingsModColor(instance, b.enumOptions, new TranslatableText("gui.settings.rpghud")));
} else {
settings.increment(b.enumOptions);
button.setMessage(new TranslatableText(settings.getButtonString(b.enumOptions)));
}
}
}).setTooltip(this.settings.getSetting(settingList.get(i)).getTooltip());
this.addDrawableChild(guismallbutton);
}
}
}
this.addDrawableChild(new ButtonWidget(this.width / 2 - 100, this.height / 6 + 168, 200, 20, new TranslatableText("gui.done"), button -> {
Settings settings = ModRPGHud.instance.settings;
for (String settingID : textFields.keySet()) {
for (TextFieldWidget t : textFields.get(settingID)) {
if (t instanceof TextFieldWidgetMod) {
ValueType type = ((TextFieldWidgetMod) t).getValueType();
switch(type) {
case DOUBLE:
double value;
try {
value = Double.valueOf(textFields.get(settingID).get(0).getText());
this.settings.getSetting(settingID).setValue(value);
} catch (NumberFormatException e) {
}
break;
case POSITION:
this.settings.getSetting(settingID).setValue(textFields.get(settingID).get(0).getText() + "_" + textFields.get(settingID).get(1).getText());
break;
}
}
}
}
settings.saveSettings();
client.setScreen(parent);
}));
}
use of net.minecraft.client.gui.widget.ButtonWidget in project como-client by gingerchicken.
the class LecternScreenMixin method init.
@Inject(at = { @At("TAIL") }, method = { "init" })
public void init(CallbackInfo ci) {
LecternCrash lecternCrash = this.getLecternCrash();
if (!lecternCrash.isEnabled())
return;
int buttonWidth = 98;
int buttonHeight = 20;
this.addDrawableChild(new ButtonWidget(this.width / 2 - buttonWidth / 2, 196 + buttonHeight + 4, buttonWidth, buttonHeight, Text.of("Crash"), button -> {
lecternCrash.doCrash();
this.close();
button.active = false;
}));
}
use of net.minecraft.client.gui.widget.ButtonWidget in project EssentialClient by senseiwells.
the class TitleScreenMixin method onInit.
@Inject(method = "initWidgetsNormal", at = @At("TAIL"))
private void onInit(CallbackInfo ci) {
if (this.client == null || !ClientRules.ESSENTIAL_CLIENT_BUTTON.getValue()) {
return;
}
ButtonWidget buttonWidget = this.addButton(new ButtonWidget(this.width / 2 - 100, this.height / 4 + 120, 200, 20, new LiteralText("Essential Client Menu"), (b) -> this.client.openScreen(new ConfigScreen(this))));
buttonWidget.active = true;
}
use of net.minecraft.client.gui.widget.ButtonWidget in project Wurst7 by Wurst-Imperium.
the class AltManagerScreen method init.
@Override
public void init() {
listGui = new ListGui(client, this, altManager.getList());
Exception folderException = altManager.getFolderException();
if (folderException != null && shouldAsk) {
TranslatableText title = new TranslatableText("gui.wurst.altmanager.folder_error.title");
TranslatableText message = new TranslatableText("gui.wurst.altmanager.folder_error.message", folderException);
TranslatableText buttonText = new TranslatableText("gui.done");
// This just sets shouldAsk to false and closes the message.
Runnable action = () -> confirmGenerate(false);
NoticeScreen screen = new NoticeScreen(action, title, message, buttonText);
client.setScreen(screen);
} else if (altManager.getList().isEmpty() && shouldAsk) {
TranslatableText title = new TranslatableText("gui.wurst.altmanager.empty.title");
TranslatableText message = new TranslatableText("gui.wurst.altmanager.empty.message");
BooleanConsumer callback = this::confirmGenerate;
ConfirmScreen screen = new ConfirmScreen(callback, title, message);
client.setScreen(screen);
}
addDrawableChild(useButton = new ButtonWidget(width / 2 - 154, height - 52, 100, 20, new LiteralText("Login"), b -> pressLogin()));
addDrawableChild(new ButtonWidget(width / 2 - 50, height - 52, 100, 20, new LiteralText("Direct Login"), b -> client.setScreen(new DirectLoginScreen(this))));
addDrawableChild(new ButtonWidget(width / 2 + 54, height - 52, 100, 20, new LiteralText("Add"), b -> client.setScreen(new AddAltScreen(this, altManager))));
addDrawableChild(starButton = new ButtonWidget(width / 2 - 154, height - 28, 75, 20, new LiteralText("Favorite"), b -> pressFavorite()));
addDrawableChild(editButton = new ButtonWidget(width / 2 - 76, height - 28, 74, 20, new LiteralText("Edit"), b -> pressEdit()));
addDrawableChild(deleteButton = new ButtonWidget(width / 2 + 2, height - 28, 74, 20, new LiteralText("Delete"), b -> pressDelete()));
addDrawableChild(new ButtonWidget(width / 2 + 80, height - 28, 75, 20, new LiteralText("Cancel"), b -> client.setScreen(prevScreen)));
addDrawableChild(importButton = new ButtonWidget(8, 8, 50, 20, new LiteralText("Import"), b -> pressImportAlts()));
addDrawableChild(exportButton = new ButtonWidget(58, 8, 50, 20, new LiteralText("Export"), b -> pressExportAlts()));
}
Aggregations