Search in sources :

Example 1 with UISliderBuilder

use of net.malisis.core.client.gui.component.interaction.slider.builder.UISliderBuilder in project Almura by AlmuraDev.

the class SimpleOptionsMenu method construct.

@SuppressWarnings({ "unchecked" })
@Override
public void construct() {
    this.saveAndLoad();
    final GeneralCategory general = configAdapter.get().general;
    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.buttonOptimized = new UIButtonBuilder(this).text("Load Optimized Defaults").size(CONTROL_WIDTH, CONTROL_HEIGHT).listener(this).build("button.optimized");
    this.updatePosition(this.buttonOptimized, Anchor.LEFT);
    this.buttonHudType = new UIButtonBuilder(this).text("HUD: " + general.hud.substring(0, 1).toUpperCase() + general.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 = general.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 = general.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 = general.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 = general.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 = general.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 = general.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);
    final boolean displayGuideOnLogin = general.displayGuideOnLogin;
    final UICheckBox checkboxDisplayGuideOnLogin = new UICheckBox(this);
    checkboxDisplayGuideOnLogin.setText(TextFormatting.WHITE + "Display Guide upon Login");
    checkboxDisplayGuideOnLogin.setChecked(displayGuideOnLogin);
    checkboxDisplayGuideOnLogin.setName("checkbox.display_guide_on_login");
    checkboxDisplayGuideOnLogin.register(this);
    this.updatePosition(checkboxDisplayGuideOnLogin, Anchor.LEFT);
    // Reset for new column
    this.lastComponent = null;
    /*
         * RIGHT COLUMN
         */
    final boolean isOrigin = general.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(general.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 == general.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 == general.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 == general.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 == general.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 == general.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 == general.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.buttonOptimized, this.buttonHudType, this.sliderOriginHudOpacity, checkboxWorldCompassWidget, checkboxLocationWidget, checkboxNumericHUDValues, checkboxDisplayNames, checkboxDisplayHealthbars, checkboxDisableOffhandTorchPlacement, checkboxDisplayGuideOnLogin, sliderChestDistance, sliderSignTextDistance, sliderItemFrameDistance, sliderPlayerNameRenderDistance, sliderEnemyNameRenderDistance, sliderAnimalNameRenderDistance, buttonDone);
    addToScreen(optionsContainer);
}
Also used : UILabel(net.malisis.core.client.gui.component.decoration.UILabel) GuiOptions(net.minecraft.client.gui.GuiOptions) GeneralCategory(com.almuradev.almura.core.client.config.category.GeneralCategory) UISliderBuilder(net.malisis.core.client.gui.component.interaction.slider.builder.UISliderBuilder) UIButtonBuilder(net.malisis.core.client.gui.component.interaction.button.builder.UIButtonBuilder) UIButton(net.malisis.core.client.gui.component.interaction.UIButton) UICheckBox(net.malisis.core.client.gui.component.interaction.UICheckBox) UIBackgroundContainer(net.malisis.core.client.gui.component.container.UIBackgroundContainer)

Aggregations

GeneralCategory (com.almuradev.almura.core.client.config.category.GeneralCategory)1 UIBackgroundContainer (net.malisis.core.client.gui.component.container.UIBackgroundContainer)1 UILabel (net.malisis.core.client.gui.component.decoration.UILabel)1 UIButton (net.malisis.core.client.gui.component.interaction.UIButton)1 UICheckBox (net.malisis.core.client.gui.component.interaction.UICheckBox)1 UIButtonBuilder (net.malisis.core.client.gui.component.interaction.button.builder.UIButtonBuilder)1 UISliderBuilder (net.malisis.core.client.gui.component.interaction.slider.builder.UISliderBuilder)1 GuiOptions (net.minecraft.client.gui.GuiOptions)1