use of net.malisis.core.client.gui.component.interaction.UICheckBox in project Almura by AlmuraDev.
the class SimpleOptionsMenu method construct.
@SuppressWarnings({ "unchecked" })
@Override
public void construct() {
final ClientCategory config = StaticAccess.config.get().client;
this.saveAndLoad();
final UILabel titleLabel = new UILabel(this, I18n.format("almura.menu_button.options"));
titleLabel.setFontOptions(FontColors.WHITE_FO);
titleLabel.setPosition(0, 20, Anchor.TOP | Anchor.CENTER);
this.addToScreen(titleLabel);
final UIBackgroundContainer optionsContainer = new UIBackgroundContainer(this, 335, 200);
optionsContainer.setBackgroundAlpha(0);
optionsContainer.setPosition(0, getPaddedY(titleLabel, CONTROL_PADDING), Anchor.TOP | Anchor.CENTER);
/*
* LEFT COLUMN
*/
this.buttonHudType = new UIButtonBuilder(this).text("HUD: " + config.hud.substring(0, 1).toUpperCase() + config.hud.substring(1)).size(CONTROL_WIDTH, CONTROL_HEIGHT).listener(this).build("button.hudType");
this.updatePosition(this.buttonHudType, Anchor.LEFT);
// TODO: Add builder for checkbox component
final boolean displayWorldCompassWidget = config.displayWorldCompassWidget;
final UICheckBox checkboxWorldCompassWidget = new UICheckBox(this);
checkboxWorldCompassWidget.setText(TextFormatting.WHITE + "Display World Compass Widget");
checkboxWorldCompassWidget.setChecked(displayWorldCompassWidget);
checkboxWorldCompassWidget.setName("checkbox.world_compass_widget");
checkboxWorldCompassWidget.register(this);
this.updatePosition(checkboxWorldCompassWidget, Anchor.LEFT);
final boolean displayLocationWidget = config.displayLocationWidget;
final UICheckBox checkboxLocationWidget = new UICheckBox(this);
checkboxLocationWidget.setText(TextFormatting.WHITE + "Display Location Widget");
checkboxLocationWidget.setChecked(displayLocationWidget);
checkboxLocationWidget.setName("checkbox.location_widget");
checkboxLocationWidget.register(this);
this.updatePosition(checkboxLocationWidget, Anchor.LEFT);
final boolean displayNumericHUDValues = config.displayNumericHUDValues;
final UICheckBox checkboxNumericHUDValues = new UICheckBox(this);
checkboxNumericHUDValues.setText(TextFormatting.WHITE + "Display Numeric HUD Values");
checkboxNumericHUDValues.setChecked(displayNumericHUDValues);
checkboxNumericHUDValues.setName("checkbox.numeric_hud_values");
checkboxNumericHUDValues.register(this);
this.updatePosition(checkboxNumericHUDValues, Anchor.LEFT);
final boolean displayNames = config.displayNames;
final UICheckBox checkboxDisplayNames = new UICheckBox(this);
checkboxDisplayNames.setText(TextFormatting.WHITE + "Display Entity Names");
checkboxDisplayNames.setChecked(displayNames);
checkboxDisplayNames.setName("checkbox.display_names");
checkboxDisplayNames.register(this);
this.updatePosition(checkboxDisplayNames, Anchor.LEFT);
final boolean displayHealthbars = config.displayHealthbars;
final UICheckBox checkboxDisplayHealthbars = new UICheckBox(this);
checkboxDisplayHealthbars.setText(TextFormatting.WHITE + "Display Entity Healthbars");
checkboxDisplayHealthbars.setChecked(displayHealthbars);
checkboxDisplayHealthbars.setName("checkbox.display_healthbars");
checkboxDisplayHealthbars.register(this);
this.updatePosition(checkboxDisplayHealthbars, Anchor.LEFT);
final boolean disableOffhandTorchPlacement = config.disableOffhandTorchPlacement;
final UICheckBox checkboxDisableOffhandTorchPlacement = new UICheckBox(this);
checkboxDisableOffhandTorchPlacement.setText(TextFormatting.WHITE + "Disable Offhand Torch Placement");
checkboxDisableOffhandTorchPlacement.setChecked(disableOffhandTorchPlacement);
checkboxDisableOffhandTorchPlacement.setName("checkbox.disable_offhand_torch_placement");
checkboxDisableOffhandTorchPlacement.register(this);
this.updatePosition(checkboxDisableOffhandTorchPlacement, Anchor.LEFT);
// Reset for new column
this.lastComponent = null;
/*
* RIGHT COLUMN
*/
final boolean isOrigin = config.hud.equalsIgnoreCase(HUDType.ORIGIN);
this.sliderOriginHudOpacity = new UISliderBuilder(this, Converter.<Float, Integer>from(f -> (int) (f * 255), i -> (float) i / 255)).text("HUD Opacity: %d").value(config.originHudOpacity).size(CONTROL_WIDTH, CONTROL_HEIGHT).listener(this).enabled(isOrigin).build("slider.originHudOpacity");
this.sliderOriginHudOpacity.setAlpha(isOrigin ? 255 : 128);
this.updatePosition(this.sliderOriginHudOpacity, Anchor.RIGHT);
final UISlider<OptionsConverter.Options> sliderChestDistance = new UISliderBuilder(this, OPTIONS_CONVERTER).text("Chest Distance: %s").value(Arrays.stream(OptionsConverter.Options.values()).filter(o -> o.value == config.chestRenderDistance).findFirst().orElse(OptionsConverter.Options.DEFAULT)).size(CONTROL_WIDTH, CONTROL_HEIGHT).listener(this).build("slider.chestRenderDistance");
this.updatePosition(sliderChestDistance, Anchor.RIGHT);
final UISlider<OptionsConverter.Options> sliderSignTextDistance = new UISliderBuilder(this, OPTIONS_CONVERTER).text("Sign Text Distance: %s").value(Arrays.stream(OptionsConverter.Options.values()).filter(o -> o.value == config.signTextRenderDistance).findFirst().orElse(OptionsConverter.Options.DEFAULT)).size(CONTROL_WIDTH, CONTROL_HEIGHT).listener(this).build("slider.signTextRenderDistance");
this.updatePosition(sliderSignTextDistance, Anchor.RIGHT);
final UISlider<OptionsConverter.Options> sliderItemFrameDistance = new UISliderBuilder(this, OPTIONS_CONVERTER).text("Item Frame Distance: %s").value(Arrays.stream(OptionsConverter.Options.values()).filter(o -> o.value == config.itemFrameRenderDistance).findFirst().orElse(OptionsConverter.Options.DEFAULT)).size(CONTROL_WIDTH, CONTROL_HEIGHT).listener(this).build("slider.itemFrameRenderDistance");
this.updatePosition(sliderItemFrameDistance, Anchor.RIGHT);
final UISlider<OptionsConverter.Options> sliderPlayerNameRenderDistance = new UISliderBuilder(this, OPTIONS_CONVERTER).text("Player Name Distance: %s").value(Arrays.stream(OptionsConverter.Options.values()).filter(o -> o.value == config.playerNameRenderDistance).findFirst().orElse(OptionsConverter.Options.DEFAULT)).size(CONTROL_WIDTH, CONTROL_HEIGHT).listener(this).build("slider.playerNameRenderDistance");
this.updatePosition(sliderPlayerNameRenderDistance, Anchor.RIGHT);
final UISlider<OptionsConverter.Options> sliderEnemyNameRenderDistance = new UISliderBuilder(this, OPTIONS_CONVERTER).text("Enemy Name Distance: %s").value(Arrays.stream(OptionsConverter.Options.values()).filter(o -> o.value == config.enemyNameRenderDistance).findFirst().orElse(OptionsConverter.Options.DEFAULT)).size(CONTROL_WIDTH, CONTROL_HEIGHT).listener(this).build("slider.enemyNameRenderDistance");
this.updatePosition(sliderEnemyNameRenderDistance, Anchor.RIGHT);
final UISlider<OptionsConverter.Options> sliderAnimalNameRenderDistance = new UISliderBuilder(this, OPTIONS_CONVERTER).text("Animal Name Distance: %s").value(Arrays.stream(OptionsConverter.Options.values()).filter(o -> o.value == config.animalNameRenderDistance).findFirst().orElse(OptionsConverter.Options.DEFAULT)).size(CONTROL_WIDTH, CONTROL_HEIGHT).listener(this).build("slider.animalNameRenderDistance");
this.updatePosition(sliderAnimalNameRenderDistance, Anchor.RIGHT);
final UIButton buttonDone = new UIButtonBuilder(this).text(I18n.format("gui.done")).size(200, CONTROL_HEIGHT).position(0, this.lastComponent == null ? 10 : getPaddedY(this.lastComponent, 10)).anchor(Anchor.TOP | Anchor.CENTER).listener(this).build("button.done");
optionsContainer.add(this.buttonHudType, this.sliderOriginHudOpacity, checkboxWorldCompassWidget, checkboxLocationWidget, checkboxNumericHUDValues, checkboxDisplayNames, checkboxDisplayHealthbars, checkboxDisableOffhandTorchPlacement, sliderChestDistance, sliderSignTextDistance, sliderItemFrameDistance, sliderPlayerNameRenderDistance, sliderEnemyNameRenderDistance, sliderAnimalNameRenderDistance, buttonDone);
addToScreen(optionsContainer);
}
Aggregations