use of net.minecraft.client.gui.widget.ButtonWidget in project SpeedRunIGT by RedLime.
the class SpeedRunCategoryScreen method init.
@Override
protected void init() {
assert client != null;
addButton(new ButtonWidget(width / 2 - 100, height - 35, 200, 20, ScreenTexts.CANCEL, button -> client.openScreen(parent)));
this.listWidget = new CategorySelectionListWidget(client);
addChild(listWidget);
}
use of net.minecraft.client.gui.widget.ButtonWidget in project SpeedRunIGT by RedLime.
the class SpeedRunOptionScreen method init.
@Override
protected void init() {
super.init();
categorySubButtons.clear();
categorySelectButtons.clear();
tooltips.clear();
List<OptionButtonFactory> optionButtonFactoryList = SpeedRunOption.getOptionButtonFactories();
int categoryCount = 0;
for (OptionButtonFactory factory : optionButtonFactoryList) {
OptionButtonFactory.Storage builder = factory.create(this).build();
AbstractButtonWidget button = builder.getButtonWidget();
if (builder.getTooltip() != null)
tooltips.put(button, builder.getTooltip());
String category = builder.getCategory();
ArrayList<AbstractButtonWidget> categoryList = categorySubButtons.getOrDefault(category, new ArrayList<>());
categoryList.add(button);
categorySubButtons.put(category, categoryList);
if (!categorySelectButtons.containsKey(category)) {
ButtonWidget buttonWidget = new ButtonWidget(width - 110, 30 + (categoryCount++ * 22), 80, 20, new TranslatableText(category), (ButtonWidget buttonWidget1) -> selectCategory(category));
categorySelectButtons.put(category, buttonWidget);
addButton(buttonWidget);
}
}
addButton(new ButtonWidget(width - 85, height - 35, 70, 20, ScreenTexts.CANCEL, (ButtonWidget button) -> onClose()));
addButton(new ButtonWidget(15, height - 35, 70, 20, new TranslatableText("speedrunigt.menu.donate"), (ButtonWidget button) -> Util.getOperatingSystem().open("https://ko-fi.com/redlimerl")));
buttonListWidget = addChild(new ButtonScrollListWidget());
categorySelectButtons.keySet().stream().findFirst().ifPresent(this::selectCategory);
}
use of net.minecraft.client.gui.widget.ButtonWidget in project SpeedRunIGT by RedLime.
the class TimerCustomizeScreen method initIGTButtons.
public void initIGTButtons() {
igtOptions.add(addButton(new SliderWidget(width / 2 - 127, height / 2 - 16, 120, 20, new TranslatableText("speedrunigt.option.timer_position.color_red", "IGT").append(" : ").append(String.valueOf(ColorMixer.getRed(drawer.getIGTColor()))), ColorMixer.getRed(drawer.getIGTColor()) / 255.0f) {
@Override
protected void updateMessage() {
this.setMessage(new TranslatableText("speedrunigt.option.timer_position.color_red", "IGT").append(" : ").append(String.valueOf(ColorMixer.getRed(drawer.getIGTColor()))));
}
@Override
protected void applyValue() {
int color = drawer.getIGTColor();
drawer.setIGTColor(ColorMixer.getArgb(ColorMixer.getAlpha(color), (int) (this.value * 255), ColorMixer.getGreen(color), ColorMixer.getBlue(color)));
changed = true;
}
}));
igtOptions.add(addButton(new SliderWidget(width / 2 - 127, height / 2 + 6, 120, 20, new TranslatableText("speedrunigt.option.timer_position.color_green", "IGT").append(" : ").append(String.valueOf(ColorMixer.getGreen(drawer.getIGTColor()))), ColorMixer.getGreen(drawer.getIGTColor()) / 255.0f) {
@Override
protected void updateMessage() {
this.setMessage(new TranslatableText("speedrunigt.option.timer_position.color_green", "IGT").append(" : ").append(String.valueOf(ColorMixer.getGreen(drawer.getIGTColor()))));
}
@Override
protected void applyValue() {
int color = drawer.getIGTColor();
drawer.setIGTColor(ColorMixer.getArgb(ColorMixer.getAlpha(color), ColorMixer.getRed(color), (int) (this.value * 255), ColorMixer.getBlue(color)));
changed = true;
}
}));
igtOptions.add(addButton(new SliderWidget(width / 2 - 127, height / 2 + 28, 120, 20, new TranslatableText("speedrunigt.option.timer_position.color_blue", "IGT").append(" : ").append(String.valueOf(ColorMixer.getBlue(drawer.getIGTColor()))), ColorMixer.getBlue(drawer.getIGTColor()) / 255.0f) {
@Override
protected void updateMessage() {
this.setMessage(new TranslatableText("speedrunigt.option.timer_position.color_blue", "IGT").append(" : ").append(String.valueOf(ColorMixer.getBlue(drawer.getIGTColor()))));
}
@Override
protected void applyValue() {
int color = drawer.getIGTColor();
drawer.setIGTColor(ColorMixer.getArgb(ColorMixer.getAlpha(color), ColorMixer.getRed(color), ColorMixer.getGreen(color), (int) (this.value * 255)));
changed = true;
}
}));
igtOptions.add(addButton(new SliderWidget(width / 2 + 6, height / 2 - 16, 120, 20, new TranslatableText("speedrunigt.option.timer_position.scale", "IGT").append(" : ").append(((int) (drawer.getIGTScale() * 100)) + "%"), drawer.getIGTScale() / 3f) {
@Override
protected void updateMessage() {
this.setMessage(new TranslatableText("speedrunigt.option.timer_position.scale", "IGT").append(" : ").append(((int) (drawer.getIGTScale() * 100)) + "%"));
}
@Override
protected void applyValue() {
drawer.setIGTScale(Math.round((float) this.value * 3f * 20f) / 20f);
changed = true;
}
}));
igtOptions.add(addButton(new ButtonWidget(width / 2 + 6, height / 2 + 6, 120, 20, new TranslatableText("speedrunigt.option.timer_position.text_decorate", "IGT").append(" : ").append(new TranslatableText("speedrunigt.option.timer_position.text_decorate." + drawer.getIGTDecoration().name().toLowerCase(Locale.ROOT))), (ButtonWidget button) -> {
int order = drawer.getIGTDecoration().ordinal();
drawer.setIGTDecoration(TimerDecoration.values()[(++order) % TimerDecoration.values().length]);
changed = true;
button.setMessage(new TranslatableText("speedrunigt.option.timer_position.text_decorate", "IGT").append(" : ").append(new TranslatableText("speedrunigt.option.timer_position.text_decorate." + drawer.getIGTDecoration().name().toLowerCase(Locale.ROOT))));
})));
}
use of net.minecraft.client.gui.widget.ButtonWidget in project SpeedRunIGT by RedLime.
the class TimerCustomizeScreen method initRTAButtons.
public void initRTAButtons() {
rtaOptions.add(addButton(new SliderWidget(width / 2 - 127, height / 2 - 16, 120, 20, new TranslatableText("speedrunigt.option.timer_position.color_red", "RTA").append(" : ").append(String.valueOf(ColorMixer.getRed(drawer.getRTAColor()))), ColorMixer.getRed(drawer.getRTAColor()) / 255.0f) {
@Override
protected void updateMessage() {
this.setMessage(new TranslatableText("speedrunigt.option.timer_position.color_red", "RTA").append(" : ").append(String.valueOf(ColorMixer.getRed(drawer.getRTAColor()))));
}
@Override
protected void applyValue() {
int color = drawer.getRTAColor();
drawer.setRTAColor(ColorMixer.getArgb(ColorMixer.getAlpha(color), (int) (this.value * 255), ColorMixer.getGreen(color), ColorMixer.getBlue(color)));
changed = true;
}
}));
rtaOptions.add(addButton(new SliderWidget(width / 2 - 127, height / 2 + 6, 120, 20, new TranslatableText("speedrunigt.option.timer_position.color_green", "RTA").append(" : ").append(String.valueOf(ColorMixer.getGreen(drawer.getRTAColor()))), ColorMixer.getGreen(drawer.getRTAColor()) / 255.0f) {
@Override
protected void updateMessage() {
this.setMessage(new TranslatableText("speedrunigt.option.timer_position.color_green", "RTA").append(" : ").append(String.valueOf(ColorMixer.getGreen(drawer.getRTAColor()))));
}
@Override
protected void applyValue() {
int color = drawer.getRTAColor();
drawer.setRTAColor(ColorMixer.getArgb(ColorMixer.getAlpha(color), ColorMixer.getRed(color), (int) (this.value * 255), ColorMixer.getBlue(color)));
changed = true;
}
}));
rtaOptions.add(addButton(new SliderWidget(width / 2 - 127, height / 2 + 28, 120, 20, new TranslatableText("speedrunigt.option.timer_position.color_blue", "RTA").append(" : ").append(String.valueOf(ColorMixer.getBlue(drawer.getRTAColor()))), ColorMixer.getBlue(drawer.getRTAColor()) / 255.0f) {
@Override
protected void updateMessage() {
this.setMessage(new TranslatableText("speedrunigt.option.timer_position.color_blue", "RTA").append(" : ").append(String.valueOf(ColorMixer.getBlue(drawer.getRTAColor()))));
}
@Override
protected void applyValue() {
int color = drawer.getRTAColor();
drawer.setRTAColor(ColorMixer.getArgb(ColorMixer.getAlpha(color), ColorMixer.getRed(color), ColorMixer.getGreen(color), (int) (this.value * 255)));
changed = true;
}
}));
rtaOptions.add(addButton(new SliderWidget(width / 2 + 6, height / 2 - 16, 120, 20, new TranslatableText("speedrunigt.option.timer_position.scale", "RTA").append(" : ").append(((int) (drawer.getRTAScale() * 100)) + "%"), drawer.getRTAScale() / 3f) {
@Override
protected void updateMessage() {
this.setMessage(new TranslatableText("speedrunigt.option.timer_position.scale", "RTA").append(" : ").append(((int) (drawer.getRTAScale() * 100)) + "%"));
}
@Override
protected void applyValue() {
drawer.setRTAScale(Math.round((float) this.value * 3f * 20f) / 20f);
changed = true;
}
}));
rtaOptions.add(addButton(new ButtonWidget(width / 2 + 6, height / 2 + 6, 120, 20, new TranslatableText("speedrunigt.option.timer_position.text_decorate", "RTA").append(" : ").append(new TranslatableText("speedrunigt.option.timer_position.text_decorate." + drawer.getRTADecoration().name().toLowerCase(Locale.ROOT))), (ButtonWidget button) -> {
int order = drawer.getRTADecoration().ordinal();
drawer.setRTADecoration(TimerDecoration.values()[(++order) % TimerDecoration.values().length]);
changed = true;
button.setMessage(new TranslatableText("speedrunigt.option.timer_position.text_decorate", "RTA").append(" : ").append(new TranslatableText("speedrunigt.option.timer_position.text_decorate." + drawer.getRTADecoration().name().toLowerCase(Locale.ROOT))));
})));
}
use of net.minecraft.client.gui.widget.ButtonWidget in project BlockMeter by ModProg.
the class ColorButton method init.
@Override
protected void init() {
ModConfig config = BlockMeterClient.getConfigManager().getConfig();
// Create Color Selector
for (int i = 0; i < 4; ++i) {
for (int j = 0; j < 4; ++j) {
final int colorIndex = i * 4 + j;
this.addDrawableChild(new ColorButton(this.width / 2 - 44 + j * 22, this.height / 2 - 88 + i * 22, 20, 20, null, DyeColor.byId(colorIndex).getColorComponents(), config.colorIndex == colorIndex, false, button -> {
ClientMeasureBox.setColorIndex(colorIndex);
final ClientMeasureBox currentBox = BlockMeterClient.getInstance().getCurrentBox();
if (currentBox != null)
currentBox.setColor(DyeColor.byId(colorIndex));
MinecraftClient.getInstance().setScreen((Screen) null);
}));
}
}
this.addDrawableChild(new ButtonWidget(this.width / 2 - BUTTONWIDTH / 2, this.height / 2 + 10, BUTTONWIDTH, 20, new TranslatableText("blockmeter.keepColor", new Object[] { new TranslatableText(config.incrementColor ? "options.off" : "options.on") }), button -> {
config.incrementColor = !config.incrementColor;
MinecraftClient.getInstance().setScreen((Screen) null);
// Todo find a way to increment to a new Color if a box was created while
// incrementColor was disabled
BlockMeterClient.getConfigManager().save();
}));
this.addDrawableChild(new ButtonWidget(this.width / 2 - BUTTONWIDTH / 2, this.height / 2 + 32, BUTTONWIDTH, 20, new TranslatableText("blockmeter.diagonal", new Object[] { new TranslatableText(config.innerDiagonal ? "options.on" : "options.off") }), button -> {
System.err.println("IDK WHAT YOU ARE DOING");
config.innerDiagonal = !config.innerDiagonal;
MinecraftClient.getInstance().setScreen((Screen) null);
BlockMeterClient.getConfigManager().save();
}));
this.addDrawableChild(new ButtonWidget(this.width / 2 - BUTTONWIDTH / 2, this.height / 2 + 54, BUTTONWIDTH, 20, new TranslatableText("blockmeter.showOthers", new Object[] { new TranslatableText(config.showOtherUsersBoxes ? "options.on" : "options.off") }), button -> {
System.err.println("IDK WHAT YOU ARE DOING");
config.showOtherUsersBoxes = !config.showOtherUsersBoxes;
MinecraftClient.getInstance().setScreen((Screen) null);
BlockMeterClient.getConfigManager().save();
}));
}
Aggregations